[英]How to access public address of smart contract from js?
我有一個所有者的公共地址
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()
就這樣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.