小编Jua*_*ola的帖子

如何从 Hardhat 上的助记词生成匹配的 RSK 帐户?

我已经遵循了这个Hardhat 教程。但我正在修改配置文件以使其在RSK上运行上工作,\n并且遇到了一些意外的地址行为。\n\xe2\x80\x8b

\n
const { expect } = require(\'chai\');\n\xe2\x80\x8b\ndescribe(\'Token contract\', () => {\n  it(\'Deployment should assign the total supply of tokens to the owner\', async () => {\n    const [owner] = await ethers.getSigners();\n    console.log(\'Smart contract owner: \', owner.address);\n      \n    const Token = await ethers.getContractFactory(\'Token\');\n\xe2\x80\x8b\n    const hardhatToken = await Token.deploy();\n    \n    const ownerBalance = await hardhatToken.balanceOf(owner.address);\n    expect(await hardhatToken.totalSupply()).to.equal(ownerBalance);\n  });\n});\n
Run Code Online (Sandbox Code Playgroud)\n

\xe2\x80\x8b\n这里是hardhat.config.js我正在使用的设置:\n\xe2\x80\x8b

\n
require(\'@nomiclabs/hardhat-waffle\');\nconst fs = require(\'fs\');\n\xe2\x80\x8b\nconst minimumGasPriceTestnet = 65164000;\nconst TESTNET_GAS_MULT = 1;\nconst mnemonic = fs.readFileSync(\'.secret\', …
Run Code Online (Sandbox Code Playgroud)

rsk hardhat

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

如何将 useDApp 连接到 Rootstock 网络?

我正在创建一个 React.js DApp,它将与Rootstock (RSK)部署的智能合约进行交互。\n最近我遇到了一个名为的 React 库useDApp的 React 库。该库使用 React 挂钩和上下文提供程序自动执行区块链连接、智能合约交互和发送交易。\n\xe2\x80\x8b\n例如:

\n
const { activateBrowserWallet, account } = useEthers();\nconst etherBalance = useEtherBalance(account);\n
Run Code Online (Sandbox Code Playgroud)\n

\xe2\x80\x8b\n但是,我在支持的网络中没有看到 Rootstock。\n\xe2\x80\x8b

\n

我尝试按照文档中的描述创建 Rootstock 配置创建 Rootstock 配置:\n\xe2\x80\x8b

\n
const config = {\n  readOnlyChainId: 30,\n  readOnlyUrls: {\n    31: \'https://public-node.testnet.rsk.co\',\n    30: \'https://public-node.rsk.co\',\n  },\n};\n
Run Code Online (Sandbox Code Playgroud)\n

\xe2\x80\x8b\n不幸的是,添加上述内容似乎还不够,\n我无法连接到 RSK 主网或 RSK 测试网。

\n

是否可以配置useDApp 连接到 Rootstock?

\n

javascript reactjs decentralized-applications rsk usedapp

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

在 Hardhat 中测试智能合约时如何获得特定数量的签名者?

我正在 Hardhat 中开发智能合约并在RSK Testnet上进行测试。\n为了创建签名者帐户,我使用助记符种子短语\n和以下 Hardhat 配置:\n\xe2\x80\x8b

\n
require(\'@nomicfoundation/hardhat-toolbox\');\nconst { mnemonic } = require(\'./.secret.json\');\n\xe2\x80\x8b\n/** @type import(\'hardhat/config\').HardhatUserConfig */\nmodule.exports = {\n  solidity: \'0.8.16\',\n  networks: {\n    hardhat: {},\n    rsktestnet: {\n      chainId: 31,\n      url: \'https://public-node.testnet.rsk.co/\',\n      accounts: { // <-- here\n        mnemonic,\n        path: "m/44\'/60\'/0\'/0",\n      },\n    },\n  },\n  // ...\n};\n
Run Code Online (Sandbox Code Playgroud)\n

\xe2\x80\x8b\n在我的测试中,我通常使用ethers.js辅助函数\n在我的测试中获取签名者数组:\n\xe2\x80\x8b

\n
const signers = await hre.ethers.getSigners();\n
Run Code Online (Sandbox Code Playgroud)\n

\xe2\x80\x8b\n但是这个函数返回 20 个签名者钱包。\n如果我不想要这个默认数量,有没有办法获得特定数量的钱包?

\n

rsk ethers.js hardhat

3
推荐指数
1
解决办法
530
查看次数