Skip to content

Instantly share code, notes, and snippets.

@dmdque
Created February 12, 2019 19:39
Show Gist options
  • Save dmdque/721bbd7c44ab63d06426806138714229 to your computer and use it in GitHub Desktop.
Save dmdque/721bbd7c44ab63d06426806138714229 to your computer and use it in GitHub Desktop.

Run the following:

ganache-cli  # In its own terminal
# mkdir && cd into a new directory
truffle unbox
npm install openzeppelin-solidity@2.1

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment