This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ERC20 = artifacts.require("ERC20"); | |
module.exports = function(deployer) { | |
deployer.deploy(ERC20, "Winnie the coin", "WTC", 2, 1000000); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var HDWalletProvider = require("truffle-hdwallet-provider"); | |
var privateKeys = ["First Private Key", "Second Private Key"]; | |
module.exports = { | |
networks: { | |
development: { | |
host: "127.0.0.1", | |
port: 7545, | |
network_id: "*" | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ERC20 as ERC20 | |
owner: public(address) | |
tokenAddress: public(address) | |
erc20: ERC20 | |
@public | |
def __init__(_tokenAddress: address): | |
self.owner = msg.sender | |
self.tokenAddress = _tokenAddress |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SellToken = artifacts.require("SellToken"); | |
module.exports = function(deployer) { | |
deployer.deploy(SellToken, "0x7CC3C57cf280961b85920533A49cd62f176ef0E1"); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addLiquidity() public payable returns(uint[3] memory) { | |
require(msg.value == ETHAmount); | |
require(Dai.transferFrom(msg.sender, address(this), DaiAmount)); | |
// Do remember to approve | |
Dai.approve(address(uniswapV2Router01), DaiAmount); | |
(addLiquidityResult[0], addLiquidityResult[1], addLiquidityResult[2]) = uniswapV2Router01.addLiquidityETH{value: ETHAmount}( | |
DaiAddress, DaiAmount, 0, 0, msg.sender, now + 120); | |
return addLiquidityResult; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IUniswapV2Router01 immutable uniswapV2Router01; | |
ERC20 immutable Dai; | |
CErc20 immutable cDai; | |
address public WETHAddress; | |
address public DaiAddress; | |
address public cDaiAddress; | |
uint public DaiAmount; | |
uint public ETHAmount; | |
uint[3] public addLiquidityResult; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function swapETHToDai() public payable returns(uint[] memory) { | |
// static array: address[k] memory array; | |
// The following is the dynamic array way of initialization | |
address[] memory _paths = new address[](2); | |
// Also, push() is for storage array. | |
_paths[0] = WETHAddress; | |
_paths[1] = DaiAddress; | |
return uniswapV2Router01.swapExactETHForTokens{value: msg.value}(0, _paths, msg.sender, now + 120); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// contract instance | |
CErc20 immutable cDai; | |
// constructor() { | |
cDaiAddress = 0x6D7F0754FFeb405d23C51CE938289d4835bE3b14; | |
cDai = CErc20(cDaiAddress); | |
// } | |
function swapETHToDaiToCompound() public payable returns(bool){ | |
address[] memory _paths = new address[](2); |
OlderNewer