Bibek Koirala
Bibek Koirala

Reputation: 330

How to access public address of smart contract from js?

I have a public address of owner of

address public owner;

I want to acess it inside a js function. I tried to call it from the instance of the deployed contract but it shows something like

 ƒ () {
       var instance = this;
       var args = Array.prototype.slice.call(arguments);
       var tx_params = {};
       var last_arg = args[args.length - 1];

       // It's only tx_params …

in console.

Upvotes: 0

Views: 84

Answers (1)

Zulhilmi Zainudin
Zulhilmi Zainudin

Reputation: 9365

Assuming your contract name is Cat and you have address public owner; line inside it.

Here is the code that you can use in $ truffle console terminal after you deploy the contract:

c = Cat.at("put Cat contract address here")
c.owner.call()

That's all.

Upvotes: 1

Related Questions