简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM