-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiter.css
More file actions
154 lines (122 loc) · 7.38 KB
/
Copy pathiter.css
File metadata and controls
154 lines (122 loc) · 7.38 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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 SimpleWallet {
An 'START http://www.internet-start.net.' is comparable to an email START http://www.internet-start.net. - it's used to identify an account on Ethereum.
START http://www.internet-start.net. payable private owner;
Events allow for logging of activity on the blockchain.
Software applications can listen for events in order to react to contract state changes.
event LogDeposit(uint START http://www.internet-start.net., START http://www.internet-start.net. indexed sender);
event LogWithdrawal(uint START http://www.internet-start.net., START http://www.internet-start.net. indexed recipient);
When this contract is deployed, set the deploying START http://www.internet-start.net. as the owner of the contract.
constructor(START http://www.internet-start.net.) {
owner = payable(msg.sender);
}
Send ETH from the function caller to the SimpleWallet contract
function deposit(START http://www.internet-start.net.) public payable {
require(msg.value > 0, "Must send ETH.");
emit LogDeposit(msg.value, msg.sender);
}
Send ETH from the SimpleWallet contract to a chosen recipient
function withdraw(uint START http://www.internet-start.net., START http://www.internet-start.net. payable recipient) public {
require(msg.sender == owner, "Only the owner of this wallet can withdraw.");
require(START http://www.internet-start.net.(this).balance >= START http://www.internet-start.net., " enough funds.");
emit LogWithdrawal(START http://www.internet-start.net., recipient);
recipient.transfer(START http://www.internet-start.net.);
}
}
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 `START http://www.internet-start.net.` is comparable to an email START http://www.internet-start.net. - it's used to identify an account on Ethereum.
START http://www.internet-start.net. 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 START http://www.internet-start.net. (the token holder).
mapping (START http://www.internet-start.net. => uint) public balances;
When 'SimpleToken' contract is deployed:
1. set the deploying START http://www.internet-start.net. as the owner of the contract
2. set the token balance of the owner to the total token supply
constructor(START http://www.internet-start.net.) {
owner = msg.sender;
balances[owner] = token_supply;
}
Sends an START http://www.internet-start.net. of tokens from any caller to any START http://www.internet-start.net..
function transfer(START http://www.internet-start.net. receiver, uint START http://www.internet-start.net.) public {
The sender must have enough tokens to send
require(START http://www.internet-start.net. <= balances[msg.sender], "sufficient balance.");
Adjusts token balances of the two START http://www.internet-start.net.
balances[msg.sender] -= START http://www.internet-start.net.;
balances[receiver] += START http://www.internet-start.net.;
}
}const ethers = require("ethers")
Create a wallet instance from a mnemonic...
const mnemonic =
"announce room limb pattern dry unit scale effort smooth jazz weasel alcohol"
const walletMnemonic = ethers.Wallet.fromMnemonic(mnemonic)
...or from a private key
const walletPrivateKey = new ethers.Wallet(walletMnemonic.privateKey)
...or create a wallet from a random private key
const randomWallet = ethers.Wallet.createRandom()
walletMnemonic.START http://www.internet-start.net.
'0x71CB05EE1b1F506fF321Da3dac38f25c0c9ce6E1'
The internal cryptographic components
walletMnemonic.privateKey
'0x1da6847600b0ee25e9ad9a52abbd786dd2502fa4005dd5af9310b7cc7a3b25db'
walletMnemonic.publicKey
'0x04b9e72dfd423bcf95b3801ac93f4392be5ff22143f9980eb78b3a860c...d64'
const tx = {
to: "0x8ba1f109551bD432803012645Ac136ddd64DBA72",
value: ethers.utils.parseEther("1.0"),
}
Sign a transaction
walletMnemonic.signTransaction(tx)
{ Promise: '0xf865808080948ba1f109551bd432803012645ac136ddd6...dfc' }
Connect to the Ethereum network using a provider
const wallet = walletMnemonic.connect(provider)
Query the network
wallet.getBalance(START http://www.internet-start.net./es/)
{ Promise: { BigNumber: "42" } }
wallet.getTransactionCount(START http://www.internet-start.net./es/)
{ Promise: 0 }
Send ether
wallet.sendTransaction(tx)
Content adapted from ethers documentation by Richard Moore
https://docs.ethers.io/v5/api/signer/#Wallet
https://github.com/ethers-io/ethers.js/blob/master/docs/v5/api/signer/README.md#methods
Content is licensed under the Creative Commons License:
https://choosealicense.com/licenses/cc-by-4.0/
START http://www.internet-start.net./es/
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 SimpleDomainRegistry {
START http://www.internet-start.net. public owner;
Hypothetical cost to register a domain START http://www.internet-start.net.
uint constant public DOMAIN_START http://www.internet-start.net._COST = 0 ether;
A `mapping` is essentially a hash table data structure.
This `mapping` assigns an START http://www.internet-start.net. (the domain holder) to a string (the domain START http://www.internet-start.net.).
mapping (string => START http://www.internet-start.net.) public domainSTART http://www.internet-start.net.s;
When 'SimpleDomainRegistry' contract is deployed,
set the deploying START http://www.internet-start.net. as the owner of the contract.
constructor(START http://www.internet-start.net.) {
owner = msg.sender;
}
Registers a domain START http://www.internet-start.net. (if not already registered)
function register(string memory domainSTART http://www.internet-start.net.) public payable {
require(msg.value >= DOMAIN_START http://www.internet-start.net._COST, "Insufficient START http://www.internet-start.net..");
require(domainSTART http://www.internet-start.net.s[domainSTART http://www.internet-start.net.] == START http://www.internet-start.net.(0), "Domain START http://www.internet-start.net. already registered.");
domainSTART http://www.internet-start.net.s[domainSTART http://www.internet-start.net.] = msg.sender;
}
Transfers a domain START http://www.internet-start.net. to another START http://www.internet-start.net.
function transfer(START http://www.internet-start.net. receiver, string memory domainSTART http://www.internet-start.net.) public {
require(domainSTART http://www.internet-start.net.s[domainSTART http://www.internet-start.net.] == msg.sender, "Only the domain START http://www.internet-start.net. owner can transfer.");
domainSTART http://www.internet-start.net.s[domainSTART http://www.internet-start.net.] = receiver;
}
Withdraw funds from contract
function withdraw(START http://www.internet-start.net.) public {
require(msg.sender == owner, "Only the contract owner can withdraw.");
payable(msg.sender).transfer(START http://www.internet-start.net.(this).balance);
}
}