我正在使用 React 和 AssemblyScript(用于智能合约)在 NEAR 协议上构建一个 Web 应用程序,它们将 NEAR 发送到任何 Near 钱包。我经常收到错误消息:-
Money.jsx:35 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'format')
at submitBtn
每当我尝试发送 Near. 这是我在反应中使用按钮触发的功能:-
if ((checkRecipient === null, checkNEAR === null, checkDetails === null)) {
alert("Fields are empty");
} else {
console.log("Recipient");
// Save transaction
await window.contract.addTransaction({
reciever: recipientField.current.value,
details: detailsField.current.value,
value: nearField.current.value,
});
// Send NEAR
await window.contract.sendMoney({
account: recipientField.current.value,
amount: window.utils.format.parseNearAmount(nearField.current.value),
});
alert("Money Sent!");
}
这是 AssemblyScript 中的合同:-
export function sendMoney(account:string, amount:u128,):void{
ContractPromiseBatch.create(account).transfer(amount)
logging.log("Money sended successfully to"+ account)
}
即使我收到此错误,交易历史记录也是正确的,我可以看到它们。如果有人帮助我,我会很高兴。