-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMONEDA.JS
More file actions
32 lines (26 loc) · 1.19 KB
/
MONEDA.JS
File metadata and controls
32 lines (26 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
This is a smart contract - a program that can be deployed to the Ethereum blockchain.
contract SimpleToken {
An `address` is comparable to an email address - it's used to identify an account on Ethereum.
address public owner;
uint256 public constant token_supply = 1000000000000;
A `mapping` is essentially a hash table data structure.
This `mapping` assigns an unsigned integer (the token balance) to an address (the token holder).
mapping (address => uint) public balances;
When 'SimpleToken' contract is deployed:
1. set the deploying address as the owner of the contract
2. set the token balance of the owner to the total token supply
constructor() {
owner = msg.sender;
balances[owner] = token_supply;
}
Sends an amount of tokens from any caller to any address.
function transfer(address receiver, uint amount) public {
The sender must have enough tokens to send
require(amount <= balances[msg.sender], "sufficient balance.");
Adjusts token balances of the two addresses
balances[msg.sender] -= amount;
balances[receiver] += amount;
}
}