[英]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. 我想在js函数中访问它。 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;
假设您的合同名称为
Cat
并且您有address public owner;
line inside it. 里面的线。
Here is the code that you can use in $ truffle console
terminal after you deploy the contract: 部署合同后,可以在
$ truffle console
终端中使用以下代码:
c = Cat.at("put Cat contract address here")
c.owner.call()
That's all. 就这样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.