首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >硬件开发网络智能合同的所有者将被退回0x00000。

硬件开发网络智能合同的所有者将被退回0x00000。
EN

Stack Overflow用户
提问于 2022-11-10 09:29:01
回答 1查看 16关注 0票数 0

我试图通过使用安全帽进行单元测试来部署我的智能合同。部署时的所有者被返回为0x0000。尽管在编写js脚本时,我以所有者的身份从安全帽网络中分配了一个特定的地址。

代码语言:javascript
复制
const  hre = require('hardhat')
const { expect, assert } = require('chai')

describe('ProperSubsetFund', async function () {
  // Initialize Contract Var
  let deployERC20, deployer, user1, user2, trader1, trader2
  let signers

  beforeEach(async function () {
    // Getting all the signers
    signers = await hre.ethers.getSigners()
    // console.log(signers.map(item => item.address));

    // Assign addresses to roles for later use
    deployer = signers[0].address
    user1 = signers[1].address
    user2 = signers[2].address
    trader1 = signers[3].address
    trader2 = signers[4].address

    // Read Contract ERC20
    const contractERC20 = await hre.ethers.getContractFactory('ProperSubsetERC20')
    // Read Contract Launchpad
    const contractLaunchpad = await hre.ethers.getContractFactory('ProperSubsetFactory')
    // Read Contract Funds
    const contractFunds = await hre.ethers.getContractFactory('ProperSubsetFund')

    // Deploy the three contracts
    deployERC20 = await contractERC20.connect(signers[0]).deploy(true)
    
  });

  describe('Deployment and Ownership', function () {
    it('Check if the owner is the deployer', async function () {

        expect(await deployERC20.owner()).to.equal(deployer)
    });
  });
})

这些都是结果

代码语言:javascript
复制
 ProperSubsetFund
       Deployment and Ownership
         Deployment
           Should set the right owner:

      AssertionError: expected '0x00000000000000000000000000000000000…' to equal '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb…'
      + expected - actual

      -0x0000000000000000000000000000000000000000
      +0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
      
      at Context.<anonymous> (test/ProperSubsetFund.test.js:71:49)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-11-12 05:24:53

“硬帽子”不返回address(0),您的合同owner()正在返回address(0)。如果你读了终端机上面写着

代码语言:javascript
复制
 AssertionError: expected '0x00000000000000000000000000000000000…' to equal '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb…'

既然你设定了这个:

代码语言:javascript
复制
    expect(await deployERC20.owner()).to.equal(deployer)

您的硬件部署地址是'0xf39Fd6e51aad88F6F4ce6aB8827279cffFb…‘。但deployERC20.owner()是‘0x00000000000000000000000000000000000000000000000…’

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74386781

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档