小编Cro*_*war的帖子

使用带有 @usedapp 和 @ethersproject/contracts 的智能合约时出现奇怪的错误

你好,我正在尝试使用一个基于 Solidity 的合约,并使用 React 和 TypeScript 在我的前端与 Brownie 一起部署。还使用框架usedapp,正如这里的文档所说,为了与合约函数交互,我应该创建一个新合约,提供地址和ABI。这是我的代码:

import {useContractFunction, useEthers} from '@usedapp/core'
import TokenFarm from "../chain-info/contracts/TokenFarm.json"
import ERC20 from "../chain-info/contracts/MockERC20.json"
import networkMapping from "../chain-info/deployments/map.json"
import {constants, utils} from "ethers"
import {Contract} from '@ethersproject/contracts'

export const useStakeTokens = (tokenAddress: string) => {
    // chainId 
    const {chainId} = useEthers()
    // abi
    const {abi} = TokenFarm
    // address
    // const dappTokenAddress = chainId ? networkMapping[String(chainId)]["DappToken"][0] : constants.AddressZero
    const tokenFarmAddress = chainId ? networkMapping[String(chainId)]["TokenFarm"][0] : constants.AddressZero
    // approve
    const tokenFarmInterface …
Run Code Online (Sandbox Code Playgroud)

typescript blockchain ethereum solidity brownie

5
推荐指数
1
解决办法
1223
查看次数

标签 统计

blockchain ×1

brownie ×1

ethereum ×1

solidity ×1

typescript ×1