[英]SmartContracts - how to run function with "Erc.json" (javascript) (update)
大家好,
我有个问题
我尝试从 erc.json 标准与 JavaScript 智能合约功能。例如:我需要一个随机数 function 与后端的 metamask 用户地址(帐号)参考
基本上:
示例 JSON 值:
{
inputs: [{ internalType: 'address', name: 'UserKey', type: 'address' }],
name: 'RandomNumber',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function',
},
示例智能合约 function:
const daiToken = new web3.eth.Contract(
ContractABI, // ABI
address, // Sender address
chainId
)
daiToken.methods
.RandomNumber(address)
.call(ContractABI)
.then(function (result) {
console.log(result)
})
.catch(function (err) {
console.log(err, 'err')
})
这是控制台打印:
我希望我解释过:)
周末快乐..
(更新了新错误)
您是否尝试在index.js
文件<React.StrictMode><App /><React.StrictMode>
更改为<App />
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.