# Cannot read property 'address' of undefined deploying ERC20 example from documentation

**URL:** <https://forum.openzeppelin.com/t/cannot-read-property-address-of-undefined-deploying-erc20-example-from-documentation/4820>\
**Category:** Contracts\
**Created:** [November 28, 2020, 9:12am UTC](https://forum.openzeppelin.com/t/cannot-read-property-address-of-undefined-deploying-erc20-example-from-documentation/4820 "2020-11-28T09:12:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krylli96](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/krylli96/32/3707_2.png) [@Krylli96](https://forum.openzeppelin.com/u/Krylli96)\
**Post date:** [November 28, 2020, 9:12am UTC](https://forum.openzeppelin.com/t/cannot-read-property-address-of-undefined-deploying-erc20-example-from-documentation/4820/1 "2020-11-28T09:12:37Z")

</div>

Hello OpenZeppelin Community,

I am new to blockchain development and now trying out to use the ERC20 token contract. When executing the OpenZeppeling ERC20 example from the documentation ([https://docs.openzeppelin.com/contracts/3.x/erc20](https://docs.openzeppelin.com/contracts/3.x/erc20)) i run into the following issue once I execute “truffle migrate”:

```
TypeError: Cannot read property 'address' of undefined
    at Contract (C:\Users\kyril\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\contract\lib\contract\index.js:31:1)
    at TruffleContract (C:\Users\kyril\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\contract\lib\contract\constructorMethods.js:205:1)
    at module.exports (C:\Users\kyril\Desktop\ethereum\GoldToken\migrations\2_deploy_contracts.js:4:19)
    at Migration._load (C:\Users\kyril\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:54:1)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Migration.run (C:\Users\kyril\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:171:1)
    at Object.runMigrations (C:\Users\kyril\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:150:1)
    at Object.runFrom (C:\Users\kyril\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:110:1)
    at Object.runAll (C:\Users\kyril\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:114:1)
    at Object.run (C:\Users\kyril\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:79:1)
    at runMigrations (C:\Users\kyril\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:269:1)
    at C:\Users\kyril\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:231:1

```

**💻 Environment**  
Truffle v5.1.54 (core: 5.1.54)  
Solidity - 0.7.5 (solc-js)  
Node v12.19.0  
Web3.js v1.2.9

Before migrating the contract i have created a one-klick blockchain in ganache on the localhost, which i have set also in the truffle-config.js.

This is the contract, that im using:

```
    // contracts/GLDToken.sol
    // SPDX-License-Identifier: MIT
    pragma solidity ^0.7.5;
    import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
    contract GLDToken is ERC20 {
        constructor(uint256 initialSupply) public ERC20("Gold", "GLD") {
            _mint(msg.sender, initialSupply);
        }
    }

```

And my 2\_deploy\_contracts.js looks like this:

```
var SimpleToken = artifacts.require("SimpleToken");
module.exports = function(deployer) {
    deployer.deploy(SimpleToken(10000));
};

```

I would be very grateful for any help!

Best Regards,  
Kyrill

---

<div class="post-metadata">

**Author:** ![Skyge](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/skyge/32/343_2.png) [@Skyge](https://forum.openzeppelin.com/u/Skyge)\
**Post date:** [November 28, 2020, 9:14am UTC](https://forum.openzeppelin.com/t/cannot-read-property-address-of-undefined-deploying-erc20-example-from-documentation/4820/2 "2020-11-28T09:14:41Z")

</div>

It seems like you do not provide a valid account to deploy the contract, so what is your `truffle-config.js`

---

<div class="post-metadata">

**Author:** ![Krylli96](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/krylli96/32/3707_2.png) [@Krylli96](https://forum.openzeppelin.com/u/Krylli96)\
**Post date:** [November 28, 2020, 8:22pm UTC](https://forum.openzeppelin.com/t/cannot-read-property-address-of-undefined-deploying-erc20-example-from-documentation/4820/3 "2020-11-28T20:22:24Z")

</div>

This is the truffle-config.js i used:

```
module.exports = {
  networks: {
    development: {
     host: "127.0.0.1", // Localhost (default: none)
     port: 7545, // Standard Ethereum port (default: none)
     network_id: "*", // Any network (default: none)  
    // from: 0x379eB8217Ad3FdfD4999E487Eaff82cf28044c8e
    },
  },
  // Set default mocha options here, use special reporters etc.
  mocha: {
    // timeout: 100000
  },
  // Configure your compilers
  compilers: {
    solc: {
      version: "0.7.5", // Fetch exact version from solc-bin (default: truffle's version)
      settings: { // See the solidity docs for advice about optimization and evmVersion
       optimizer: {
         enabled: false,
         runs: 200
       }
     }
    }
  }
}

```

When adding a "from: " to the development network configuration I get the following error:  
`Error: while migrating Migrations: Returned error: sender account not recognized`

---

<div class="post-metadata">

**Author:** ![Skyge](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/skyge/32/343_2.png) [@Skyge](https://forum.openzeppelin.com/u/Skyge)\
**Post date:** [November 29, 2020, 3:38am UTC](https://forum.openzeppelin.com/t/cannot-read-property-address-of-undefined-deploying-erc20-example-from-documentation/4820/4 "2020-11-29T03:38:08Z")

</div>

Okay, so have you started your local node, such as `ganache-cli --port=7545 --gasLimit=8000000 --accounts=10 --defaultBalanceEther=10000`?

---

<div class="post-metadata">

**Author:** ![Krylli96](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/krylli96/32/3707_2.png) [@Krylli96](https://forum.openzeppelin.com/u/Krylli96)\
**Post date:** [November 29, 2020, 8:20am UTC](https://forum.openzeppelin.com/t/cannot-read-property-address-of-undefined-deploying-erc20-example-from-documentation/4820/5 "2020-11-29T08:20:47Z")

</div>

I have the Ganache UI running, which should be doing the same in the background. But after trying with creating ganache in the cli, i got the exact same error.

When removing the constructor’s parameters and calling the \_mint function with the initialsupply as a uint from the solidity smart contract, it is working. I really cant understand, why the `address undefined error` comes up when using a constructor with parameters.

---

<div class="post-metadata">

**Author:** ![Krylli96](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/krylli96/32/3707_2.png) [@Krylli96](https://forum.openzeppelin.com/u/Krylli96)\
**Post date:** [November 29, 2020, 8:34am UTC](https://forum.openzeppelin.com/t/cannot-read-property-address-of-undefined-deploying-erc20-example-from-documentation/4820/6 "2020-11-29T08:34:43Z")

</div>

I finally got it!! It was a syntax mistake with calling the constructor from truffle in 2\_deploy\_contracts.js.  
So the deployer only accepts `SimpleToken,1000` in its parameters for the constructor instead of taking `SimpleToken(1000)`, as I have been used to initialize constructors from other programming languages.

So the 2\_deploy\_contracts.js looks like this:

```
var SimpleToken = artifacts.require("SimpleToken");
module.exports = function(deployer) {
  deployer.deploy(SimpleToken, 1000);
};

```

Anyway, thank you for your help Skyge!
