我有所有者的公共(public)地址
address public owner;
我想在js函数中访问它。我尝试从已部署合约的实例中调用它,但它显示类似
ƒ () {
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 …
在控制台中。
最佳答案
假设您的合约名称是 Cat
并且其中有 address public Owner;
行。
以下是部署合约后可以在 $ truffle console
终端中使用的代码:
c = Cat.at("put Cat contract address here")
c.owner.call()
仅此而已。
关于javascript - 如何从js访问智能合约的公共(public)地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51752866/