Skip to content

Instantly share code, notes, and snippets.

@SeptiyanAndika
Created July 19, 2021 08:52
Show Gist options
  • Save SeptiyanAndika/4b99ea009410e7d620cbf83b016d4f9a to your computer and use it in GitHub Desktop.
Save SeptiyanAndika/4b99ea009410e7d620cbf83b016d4f9a 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=soljson-v0.8.6+commit.11564f7e.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract BasicToken {
mapping(address => uint256) balances;
address owner;
constructor() {
owner = msg.sender;
}
function addBalance(address recipient, uint256 value) public {
require(owner==msg.sender,"akses hanya owner");
balances[recipient] += value;
}
function transfer(address recipient, uint256 value) public {
require(balances[msg.sender]>=value,"balance tidak cukup");
balances[msg.sender] -= value;
balances[recipient] += value;
}
function balanceOf(address account) public view returns (uint256) {
return balances[account];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment