question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Contracts with `toString()` functions panic when deployed

See original GitHub issue

Describe the bug ethers fails to deploy contracts with a toString() function. (I was developing a library, but I assume normal contracts have the same issue). There are probably other function names that conflict with native js functions. valueOf() is likely another one.

Reproduction steps Create a contract with a toString() function

library MyLibrary {
    function toString(uint256 value) public returns(string){
        // ...
    }
}

Then, attempting to deploy that contract using ethers and hardhat…

const myLibFactory = await ethers.getContractFactory('MyLibrary')
const myLib = await myLibFactory.deploy() // errors

yields this error message:

TypeError: uniqueNames[name_1].push is not a function
at /.../@ethersproject/contracts/src.ts/index.ts:717:35

Environment: Hardhat 2.4.1, ethers 5.4.6

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
zemsecommented, Sep 16, 2021

Can be reproduced with

new ethers.Contract(
  '0x0000000000000000000000000000000000000000', 
  ['function toString() external']
)
1reaction
RyanRHallcommented, Jan 3, 2022

Closing, as this seems to be fixed in 5.5.X. Thank you @ricmoo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Build a Full Stack NFT Marketplace - V2 (2022)
Has anyone received the following error? Ran into it while trying out the UI locally after running the deploy script for the first...
Read more >
1. Preparation
Our trigger contract is useless if we can't verify it works properly. So before we start developing our trigger contract, we'll need to...
Read more >
Is it considered good practice to use contract functions ...
However, the needs may change in the future and it is perfectly fine to use setters, but it is good to keep some...
Read more >
Getting Deep Into EVM: How Ethereum Works Backstage
The first thing that happens when a new contract is deployed to the Ethereum blockchain is that its account is created. As you...
Read more >
revert" in Truffle test and Truffle dev in Crowdsale - Contracts
TokenSPC.deployed().then(instance => token = instance) ... function () { // Deploy a new token and crowdsale contract for each test ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found