关灯

Contract methods calls return empty array

  [复制链接]
区块链技术 发表于 2018-12-31 22:25:23 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
 

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x

I'm quite stuck with this issue. It seems like it must work, but it doesn't :D

Have a contract on rinkeby network which is working perfectly through remix(load by address) and truffle console. However method calls through web3 client refuse to work.

init:

import Web3 from 'web3';


// @ts-ignore
const web3 = new Web3(window.web3.currentProvider);

***got address & abi***

export default new web3.eth.Contract(abi, address);

usage example:

console.log(registryContract.options.address);
console.log(registryContract.methods);
const owner = await registryContract.methods.owner().call();

In console.log() i can see the actual contract address and methods. Metamask is active and web3.eth.defaultAccount shows me my correct account at rinkeby network => provider must be working.

calling the owner from remix working. with web3 i'm getting an empty array as response. Same for other methods calls.

What is possible going wrong? "web3": "^1.0.0-beta.37"




上一篇:Output order changes after the event triggered
下一篇:web3js 1.0 fromWei throwing although passing correct type
回复

使用道具 举报

 

精彩评论3

正序浏览
区块链技术 发表于 2018-12-31 22:27:17 | 显示全部楼层
 

You have some stray brackets after the method name.

Instead of

registryContract.methods.owner().call();

try

registryContract.methods.owner.call();
回复

使用道具 举报

 
 楼主| 区块链技术 发表于 2018-12-31 22:37:30 | 显示全部楼层
 

Try this.

registryContract.owner(function (error, result) { if (!error) console.log(result); else console.error(error); });

回复

使用道具 举报

 
 楼主| 区块链技术 发表于 2018-12-31 22:46:04 | 显示全部楼层
 

The problem was with contract abi - don't know what exactly was wrong with it. I simply used abi from different source and it helped. Any tool for abis verification?

回复

使用道具 举报

 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

排行榜

关注我们:微信订阅号

官方微信

APP下载

全国服务邮箱:

admin@xuesq.cn

公司地址:重庆南岸区学府大道

运营中心:重庆微生派网络工作室

邮编:610066 Email:1401171837#qq.com

Copyright   ©2017-2018  中比特Powered by©xuesq.cn!技术支持:中比特    ( 蜀ICP备16009247号-1 )