Guest User

Untitled

a guest
Feb 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. function buyTokenFromOwner() payable {
  2. require(msg.value >= price);
  3. if (msg.value > price) {
  4. msg.sender.transfer(msg.value.sub(price));
  5. }
  6. tokens[owner] = tokens[owner].sub(1);
  7. tokens[msg.sender] = tokens[msg.sender].add(1);
  8. }
  9.  
  10. async buyToken() {
  11. let contractInstance = await TokenSaleContract.at(this.state.contractAddress);
  12. let name = await contractInstance.getName();
  13. await contractInstance.buyTokenFromOwner({ value: 107087936329796580 })
  14. }
Add Comment
Please, Sign In to add comment