我使用松露控制台部署合同,并使用Nodejs/web3js与其交互。我想使用ethereumjs-tx对事务进行签名,这里是引用链接。我不确定如何找到本地块链的链id和网络id,为此我需要创建rawtransaction。i.e
const customCommon = Common.forCustomChain(
'randomchainNmae',
{
name: 'my-network',
networkId: ???,
chainId: ???,
},
'petersburg',
)发布于 2020-04-05 08:34:26
您可以使用web3.js的web3实例获得这两种信息:
const networkId = await web3.eth.net.getId();
const chainId = await web3.eth.getChainId();发布于 2021-01-26 14:03:46
要直接回答标题,chain_id of ganache是0x539 (或1337)。
发布于 2020-12-28 06:12:32
如果您不知道network_id,那么您可以使用以下网络。检查您的truffle.js
development: {
host: '127.0.0.1',
port: 8545,
network_id: "*",
from: "", // default address to use for any transaction Truffle makes
}https://ethereum.stackexchange.com/questions/76581
复制相似问题