首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何检索从ether.js的稳固性中返回的多个值?

如何检索从ether.js的稳固性中返回的多个值?
EN

Ethereum用户
提问于 2021-06-03 04:43:50
回答 1查看 1.4K关注 0票数 3

在ethers.js文档中,它是用来检索数据的,如下所示

代码语言:javascript
复制
// 'contract' is an instance of Contract made with ethers.js
// Get the current value
let currentValue = await contract.getValue();

console.log(currentValue);
// "Hello World"

但是我的合同从智能契约函数中返回两个值。下面是该函数的接口

代码语言:javascript
复制
function targetNFT() external view returns(address _nftToken, uint256 _nftTokenId);

如何使用ethers.js检索从智能契约返回的多个值?

EN

回答 1

Ethereum用户

回答已采纳

发布于 2022-05-08 17:38:19

代码语言:javascript
复制
const result = await contractInstance.yourFunction();

const {0: variable_1, 1: variable_2} = result;

参考资料:https://blockheroes.dev/js-read-multiple-returned-values-solidity/

希望能帮上忙。

票数 3
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/100225

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档