forked from AllDigitalShop/valorem-frontend
-
Notifications
You must be signed in to change notification settings - Fork 2
/
notes
66 lines (42 loc) · 3 KB
/
notes
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
Terminology:
# Token
Ethereum tokens are smart contracts that makee use of the Ethereum blockchain. A token can represent a diverse range of digital assets like vouchers, IOUs, or even real-world tangible objects. Token is just a generic name to refer to this group.
# ERC-20 (Standard)
One of the most significant tokens is called ERC-20, which has emerged as the technical standard used for all smart contracts on the Ethereum blockchain for token implementation. Plenty of well-known digital currencies use the ERC-20 standard, including Maker (MKR), Basic Attention Token (BAT), Augur (REP), and the OMG Network (OMG).
ERC-20 has emerged as the technical standard; it is used for all smart contracts on the Ethereum blockchain for token implementation and provides a list of rules that all Ethereum-based tokens must follow.
In terms of implementation coding for ERC-20 tokens, the six basic coding functions are:
- total supply
- balance of
- allowance
- transfer
- approve
- transfer from
# Provider
A "wallet provider." For example, MetaMask. The provider "hosts" wallets locally on a user's computer for different types of tokens (e.g., DAI, ETH, etc).
A provider connects to a network (e.g., Ethereum Mainnet) and retrieves balances on that network related to the wallets for each type of token (e.g., DAI Balance, ETH Balance, etc).
# Network
A network is the blockchain being communicated with. E.g., a "testnet" would provide a blockchain used for testing applications while a "mainnet" providers a blockchain for live/production applications.
# Wallet
A wallet contains many addresses of many token types. For e.g., I can have 50 ETH addresses and 2 DAI addresses. In a provider UI (e.g., Metamask), the balances of these addresses are "totaled up" and displayed under the title of the given token.
# Address
An address (a.k.a "account") can send and receive transactions based on its current balance. E.g., the address abc123 can send some or all of its balance to def456. An addresses' balance is the sum of all of its inputs (received), minus its outputs (sent).
---
# Wallet Connection
When connecting to MetaMask, whichever wallet was currently "active" or "selected" by the user becomes the signing address once we connect.
// providers get data from smart contract
// signer is used for signing data/setting data to smart contract
---
Implementation
- When connecting a wallet, if not on the correct network, throw an error and don't allow wallet to connect until fixed.
- When creating provider
1. Check for required balance of underlyingAsset.
X 1A. If balance met, continue.
X 1B. If balance NOT met, throw an error.
2. Create and verify existence of hash of chain to create.
1A. If chain hash already exists, skip to check allowance.
1B. If chain hash doesn't exist, create it, then move to check allowance.
3. Check the allowance for the asset.
1A. If it exists, skip to write().
1B. If it doesn't exist, pop up request for approval.
1C. After approval, skip to write contract.
4. Write the contract(s).