Skip to content

Instantly share code, notes, and snippets.

@josefrichter
Created September 9, 2021 17:32
Show Gist options
  • Save josefrichter/8f3c21627dc837e841e6a935e4f28f5f to your computer and use it in GitHub Desktop.
Save josefrichter/8f3c21627dc837e841e6a935e4f28f5f to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract ERC20Token {
string public name;
mapping(address => uint256) public balances;
function mint() public {
balances[tx.origin] ++;
}
}
contract MyContract {
address payable wallet;
address public token;
constructor(address payable _wallet, address _token) {
wallet = _wallet;
token = _token;
}
fallback() external payable {
buyToken();
}
receive() external payable {
buyToken();
}
function buyToken() public payable {
// ERC20Token _token = ERC20Token(address(token));
// _token.mint();
ERC20Token(address(token)).mint();
wallet.transfer(msg.value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment