gpt4 book ai didi

javascript - 无法在 ether.js 中读取未定义的属性(读取 'toHexString')

转载 作者:行者123 更新时间:2023-12-05 01:52:46 24 4
gpt4 key购买 nike

请不要评判,我不知道该做什么,该怎么做:)

我的代码:以太.js (^5.6.0)

import { ThirdwebSDK } from '@3rdweb/sdk'
import { ethers } from 'ethers'

const sdk = new ThirdwebSDK(
new ethers.Wallet(
process.env.METAMASK_PRIVATE_KEY,
ethers.getDefaultProvider(
'https://rinkeby.infura.io/v3/'
)
)
)

错误 enter image description here

最佳答案

如果您正在使用 JavaScript 并收到此错误,那么您在导入 dotenv 时犯了一个错误。您正在使用 ".config" 作为属性。像下面这样的方法使用它

require("dotenv").config()

它会起作用。

关于javascript - 无法在 ether.js 中读取未定义的属性(读取 'toHexString'),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71460761/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com