I am deploying the contract successfully with a fixed amount of tokens. Now I wish to transfer them to my wallet either at deployment or after, but none of my functions work.
The contracts in the OpenZeppelin Contracts repository master branch are part of the upcoming OpenZeppelin Contracts 3.0 (currently at OpenZeppelin Contracts v3.0 final release candidate) and use Solidity 0.6.
I have a simple ERC777 token (using OpenZeppelin 2.5) which can be deployed using OpenZeppelin CLI or Truffle (I would need to put together an example that works in Remix):
I have originally deployed the ERC777 contract as is from github, but was unable to create the initial supply or transfer any amount to my own wallet in the Rinkbey Test environment. Have I misunderstood how the contract works? Would appreciate your guidance.
I suggest deploying the simple ERC20 token in Remix and playing with that.
I will have to try putting together a similar example for ERC777 that can be used in Remix (I just tried to do it now but had issues deploying, so will need to spend a bit more time on it in the next day or so).
OK, thanks for the quick answer and generous help. I will play around with ERC20 in the meantime. Where will you post the update once it has been modified for REMIX? Also, can you recommend some beginner level guide for truffle, would appreciate it?
When deploying to a local testnet we need to have the ERC1820 registry deployed.
Which is why I had issues last night deploying to a JavaScript VM, so instead deployed to a public testnet.
Below are versions of the Simple777Token that can be used on Remix.
Simple777Token has not been tested nor audited
Simple777Token.sol
Using OpenZeppelin Contracts 3.0
pragma solidity ^0.6.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.0.0/contracts/token/ERC777/ERC777.sol";
/**
* @title Simple777Token
* @dev Very simple ERC777 Token example, where all tokens are pre-assigned to the creator.
* Note they can later distribute these tokens as they wish using `transfer` and other
* `ERC20` or `ERC777` functions.
* Based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/examples/SimpleToken.sol
*/
contract Simple777Token is ERC777 {
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor () public ERC777("Simple777Token", "S7", new address[](0)) {
_mint(msg.sender, 10000 * 10 ** 18, "", "");
}
}
Simple777Token.sol
Using OpenZeppelin Contracts 2.5
pragma solidity ^0.5.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC777/ERC777.sol";
/**
* @title Simple777Token
* @dev Very simple ERC777 Token example, where all tokens are pre-assigned to the creator.
* Note they can later distribute these tokens as they wish using `transfer` and other
* `ERC20` or `ERC777` functions.
* Based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/examples/SimpleToken.sol
*/
contract Simple777Token is ERC777 {
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor () public ERC777("Simple777Token", "S7", new address[](0)) {
_mint(msg.sender, msg.sender, 10000 * 10 ** 18, "", "");
}
}