Run the following:
ganache-cli # In its own terminal
# mkdir && cd into a new directory
truffle unbox
npm install [email protected]
Paste into contracts/BsktToken.sol
:
pragma solidity 0.5.0;
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
contract BsktToken {
using SafeMath for uint256;
address[] public addresses;
uint256[] public quantities;
constructor(address[] memory _addresses, uint256[] memory _quantities) public {
addresses = _addresses;
quantities = _quantities;
}
function create(uint256 amount) public {
}
function redeem(uint256 amount) public {
}
}
Now we can compile using truffle compile
.
Replace the contents of migrations/2_deploy_contracts.js
with:
var BsktToken = artifacts.require("./BsktToken.sol");
module.exports = function(deployer) {
deployer.deploy(BsktToken, ['0x000000000000000000000000000000000000000A'], [1]);
};
Now we can deploy using truffle migrate
. After deploying, we can use truffle console
to interact with the contracts.
truffle console
> BsktToken.deployed()
Note that to properly test BsktToken, we'd have to deploy multiple ERC20 tokens to act as the underlying bundle, and deploy them before deploying BsktToken. I recommend completing the Truffle Pet Shop Tutorial.