Calling mint() on an ERC20Mintable token via the OpenZeppelin CLI

I have

pragma solidity ^0.5.16;

import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Detailed.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Mintable.sol";

contract MyToken  is Initializable, ERC20, ERC20Detailed, ERC20Mintable  {

  function initialize() public initializer {

    ERC20Mintable.initialize(msg.sender);
    ERC20Detailed.initialize("My Token", "MyT", 18);

  }

}

And I wish call mint() via openzeppelin/cli

But neither npx oz send-tx nor npx oz call shows me the mint() function.
I saw posts here that uses truffle to perform it.

Can I not call mint using openzeppelin/cli?

1 Like

Hi @vikram,

Welcome to the community forum :wave:

You can call mint using the OpenZeppelin CLI send-tx.

First create the token and initialize

$ npx oz create
✓ Compiled contracts with solc 0.5.16 (commit.9c3226ce)
? Pick a contract to instantiate MyToken
? Pick a network development
✓ Added contract MyToken
✓ Contract MyToken deployed
All contracts have been deployed
? Call a function to initialize the instance after creating it? Yes
? Select which function * initialize()
✓ Instance created at 0x9b1f7F645351AF3631a656421eD2e40f2802E6c0
0x9b1f7F645351AF3631a656421eD2e40f2802E6c0

Then use send-tx to call mint.
Please note we need to move down to select the mint function (use up and down arrows)

$ npx oz send-tx
? Pick a network development
? Pick an instance MyToken at 0x9b1f7F645351AF3631a656421eD2e40f2802E6c0
? Select which function
  addMinter(account: address)
  approve(spender: address, amount: uint256)
  decreaseAllowance(spender: address, subtractedValue: uint256)
❯ mint(account: address, amount: uint256)
  renounceMinter()
  transfer(recipient: address, amount: uint256)
  transferFrom(sender: address, recipient: address, amount: uint256)
(Move up and down to reveal more choices)                    

We can select the mint function and specify the recipient and the amount.

$ npx oz send-tx
? Pick a network development
? Pick an instance MyToken at 0x9b1f7F645351AF3631a656421eD2e40f2802E6c0
? Select which function mint(account: address, amount: uint256)
? account (address): 0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0
? amount (uint256): 10
✓ Transaction successful. Transaction hash: 0x02fa76cdb65d6c254426b6b24f3eb9b953da9a9bb9eba2a44ac146445cb59397
Events emitted:
 - Transfer(0x0000000000000000000000000000000000000000, 0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0, 10)

But I only see the following functions:

? Select which function (Use arrow keys)
❯ * initialize() 
  * initialize(name: string, symbol: string, decimals: uint8) 
  * initialize(sender: address) 
  increaseAllowance(spender: address, addedValue: uint256) 
  addMinter(account: address) 
  approve(spender: address, amount: uint256) 
  decreaseAllowance(spender: address, subtractedValue: uint256) 
(Move up and down to reveal more choices)
1 Like

Sorry …there are many more functions… I did not notice I could scroll !!

(Move up and down to reveal more choices)

1 Like

Hi @vikram,

Glad you can mint now.

Do you have any suggestions on how we could improve the CLI to make it easier, so other community members don’t run into the same problem?

Colored/highlighted text with up/down arrows should be helpful
^ v (Move up and down to reveal more choices) v ^

1 Like

Thanks for the feedback @vikram,

I have created an Issue for this: https://github.com/OpenZeppelin/openzeppelin-sdk/issues/1421

1 Like

Hi @vikram,

The CLI now supports deploying regular (non-upgradeable) contracts in the release candidate of OpenZeppelin CLI 2.8

Would appreciate if you could give the release candidate a try and let us know what you think!