Comment on page
Token Contracts
Smart contract documentation for the TC and TCC Tokens
Click below to view the token contract on Snowtrace 👇
View functions are identified by the
-->
symbol to explain that running the function returns the variable type that follows. For example decimals()
is a view
function that returns a uint8
whereas transfer()
is a function that changes the state – such as modifying values held in storage
– and is thus a transaction that requires gas.Functions that change the state can only pass return values to other Solidity functions within the same transaction. Gas-required transactions cannot return variables to Web3 or any frontend.
name() --> string
ERC-20 required variable. Returns a
string
to represent the name of our token. For our TC token contract, this is a constant
of Triple Confirmation
.symbol() --> string
ERC-20 required variable. Returns a
string
to represents the symbol of our token. For our TC token contract, this is a constant
of TC
.decimals() --> uint8
ERC-20 required variable. Returns a
uint8
to represent the count of integers from right that are decimals. For our TC token contract, this is a constant
of 6
.totalSupply() --> uint256
ERC-20 required variable. Returns a
uint256
to represent the total amount of TC tokens ever created. For our TC token contract, this is a constant
of 142000000000000
.balanceOf(address account) --> uint256
Returns the amount of TC owned by
account
.allowance(address owner, address spender) --> uint
Returns the remaining number of TC that
spender
will be allowed to spend on behalf of owner
through the transferFrom
function. Default value is 0
. The allowance
value changes when approve
or transferFrom
are called.transfer(address to, uint amount)
Transfers the
amount
of TC from you to a recipient
. The amount
of TC must be given in raw, unsigned uint
form, not in float form.
Emits a Transfer
event.approve(address spender, uint amount)
Sets
amount
as the allowance
of spender
over the caller's TC. Running this function grants spender
the authorisation to transferFrom
you up to the amount
submitted.
Emits an Approval
event.transferFrom(address sender, address recipient, uint amount)
Moves
amount
TC from sender
to recipient
using the allowance
mechanism. amount
is deducted from the caller's allowance
when this function is run.
Emits a Transfer
event.DOMAIN_SEPARATOR() --> bytes32
EIP-2612 required variable. For our TC token contract, this is a
constant
value of:
0xb56644a49d721fa16c77272b57de8bfa6bdcfad70abca7d271c5faf9317444a1
denominator() --> uint
Divide token values by this
uint
to obtain a float (human-readable number).rainMinimumBalance() --> uint
The minimum
balanceOf()
required for eligiblity of rain()
and rainAll()
when those functions are called by others.adminWallet() --> address
0xc25f0b6bdbb2b3c9e8ef140585c664727b3b9d60
This wallet is primarily established for the purposes of easily identifying and tracking the
treasuryWallet
across the Triple Confirmation system of contracts. The adminWallet
and treasuryWallet
both have the same authority level EXCEPT that the adminWallet
can change the treasuryWallet
without the latter's permission. Worth noting that while the adminWallet
can change the treasuryWallet
address, the adminWallet
cannot transfer tokens away from the outgoing treasuryWallet
without being given permission via sufficient allowance
.
Only the adminWallet
can replace itself and set a successor.breakAtGasThreshold() --> uint256
Gas threshold to terminate transaction if the rest amount of gas is smaller than this. For our TC, it is
50000
.chainId() --> uint256
Chain Id of AVAX chain.
43114
encodeDelegation(address owner, Delegation calldata input) --> uint256, bytes32
gasPerLoop() --> uint256
Get gas amount required for one loop. Default is
31400
.getAccount(address account) --> Account
Provide all relevant associated information of
account
.struct Account {
uint id;
address account;
uint balance;
bool protected;
Approves approvedSpenders;
RainStruct rain;
}
getAccountById(uint256 id) --> Account
Provide all relevant account information on account at
id
.getAccountsList() --> Account[]
Provide all relevant account information of all the accounts. If there's no accounts, this will revert.
getAccountsListByIds(uint256 first, uint256 last) --> Account[]
Provide all relevant account information of all the accounts between first and last accounts.
getCirculatingSupply() --> uint256
Raw value unsigned integer (uint) of
totalSupply
not under the control of adminWallet
or treasuryWallet
.getErrors() --> string[]
Returns full list of error messages.
// From the TC token contract:
[
" TC.",
"TC | AUTH: Sender must be the Admin Wallet.",
"TC | AUTH: Sender must be either the Treasury Wallet or the Admin Wallet.",
"TC | AUTH: Sender must be the Guardian Wallet, the Treasury Wallet, or the Admin Wallet.",
"TC | TRANSFER: Insufficient balance: ",
"TC | TRANSFER: Use `transferFrom()` to transfer tokens to a smart contract.",
"TC | TRANSFER-FROM: Insufficient `approve()` amount remaining: ",
"TC | TRANSFER-MULTIPLE: Count of recipients and amounts must be identical.",
"TC | LIST: First index cannot be greater than the last index.",
"TC | DELEGATE SET-ID: Count of recipients and amounts must be identical.",
"TC | SET: `id` disallowed for `account`.",
"TC | SET: `id` is protected.",
"TC | SET: New Admin Wallet cannot be set to a null address.",
"TC | SET: New Admin Wallet cannot be the same as the current one.",
"TC | SET: New Treasury Wallet cannot be set to a null address.",
"TC | SET: New Treasury Wallet cannot be the same as the current one.",
"TC | SET: `gasPerLoop` cannot be greater than 1/20 the `block.gaslimit`.",
"TC | SET: `breakAtGasThreshold` must be a greater value than `gasPerLoop`.",
"TC | SET: `breakAtGasThreshold` cannot be greater than 1/4 the `block.gaslimit`.",
"TC | SET: Maximum possible value of 4200.690000 TC.",
"TC | PERMIT ERROR: The 0 address cannot permit others.",
"TC | PERMIT ERROR: Expired deadline.",
"TC | PERMIT ERROR: Invalid signature.",
"TC | GAS: Submit with ",
"",
"TC | RAIN: Invalid `amounts` provided.",
"TC | RAIN: Must rain on at least 1 account.",
"TC | DELEGATION: Null address are disallowed from execution.",
"TC | DELEGATION: You're not the delegate or owner.",
"TC | DELEGATION: No match found.",
"TC | DELEGATION: Unsupported function.",
"TC | CLAIM ERC-20: Failed transfer.",
"TC | DECREASE ALLOWANCE: Amount to deduct is greater than existing `approve()` amount: ",
"TC | APPROVE DEADLINE: Minimum possible value is 30 seconds. Maximum possible value is 2^248."
];
// From the TCC token contract:
[
" TCC.",
"TCC | AUTH: Sender must be the Admin Wallet.",
"TCC | AUTH: Sender must be either the Treasury Wallet or the Admin Wallet.",
"TCC | AUTH: Sender must be the Guardian Wallet, the Treasury Wallet, or the Admin Wallet.",
"TCC | TRANSFER: Insufficient balance: ",
"TCC | TRANSFER: Use `transferFrom()` to transfer tokens to a smart contract.",
"TCC | TRANSFER-FROM: Insufficient `approve()` amount remaining: ",
"TCC | TRANSFER-MULTIPLE: Count of recipients and amounts must be identical.",
"TCC | LIST: First index cannot be greater than the last index.",
"TCC | DELEGATE SET-ID: Count of recipients and amounts must be identical.",
"TCC | SET: `id` disallowed for `account`.",
"TCC | SET: `id` is protected.",
"TCC | SET: New Admin Wallet cannot be set to a null address.",
"TCC | SET: New Admin Wallet cannot be the same as the current one.",
"TCC | SET: New Treasury Wallet cannot be set to a null address.",
"TCC | SET: New Treasury Wallet cannot be the same as the current one.",
"TCC | SET: `gasPerLoop` cannot be greater than 1/20 the `block.gaslimit`.",
"TCC | SET: `breakAtGasThreshold` must be a greater value than `gasPerLoop`.",
"TCC | SET: `breakAtGasThreshold` cannot be greater than 1/4 the `block.gaslimit`.",
"TCC | SET: Maximum possible value of 4200.690000 TCC.",
"TCC | PERMIT ERROR: The 0 address cannot permit others.",
"TCC | PERMIT ERROR: Expired deadline.",
"TCC | PERMIT ERROR: Invalid signature.",
"TCC | GAS: Submit with ",
"",
"TCC | RAIN: Invalid `amounts` provided.",
"TCC | RAIN: Must rain on at least 1 account.",
"TCC | DELEGATION: Null address are disallowed from execution.",
"TCC | DELEGATION: You're not the delegate or owner.",
"TCC | DELEGATION: No match found.",
"TCC | DELEGATION: Unsupported function.",
"TCC | CLAIM ERC-20: Failed transfer.",
"TCC | DECREASE ALLOWANCE: Amount to deduct is greater than existing `approve()` amount: ",
"TCC | APPROVE DEADLINE: Minimum possible value is 30 seconds. Maximum possible value is 2^248."
];
guardianWallet() --> address
guardianWallet
is created to assist adminWallet
with routine token contract management that are of low consequence. These are parameters relating to highly recursive operations such as adjusting error messages or setting team wallets to lower id
s for easier access and organizsation from getAccountsList()
calls.
Guardian wallet address of TC is 0xe524ae868b899a9d3cf7259b2579affd66c46823
.id(address account) --> uint256
Returns account id of
account
.maxRecipientsPerBlock() --> uint256
Returns the number of maximum recipients per block. This is calculated by the following formula.
maxRecipientsPerBlock = (block.gaslimit - breakAtGasThreshold) / _safeDivision(gasPerLoop)
nonces(address account) --> uint256
Returns nonce of
account
. "Nonce" is a portmanteau of "number used only once". Nonce is used with the other data to create a unique fixed-size string for validating account
inside permit
function.numAccounts() --> uint256
Returns the number of existing accounts.
supply() --> uint256
Returns the whole tokens (no decimals). Supply of TC is
142000000
.treasuryWallet() --> address
Returns the wallet address of treasury wallet of TC. It is
0xc25f0b6bdbb2b3c9e8ef140585c664727b3b9d60
.version() --> string
Returns version of TC. Latest version of TC is
1
.versionNotes() --> string
Returns information of the current version. TC's version note is
2023-04-20 | Final
.addAccounts(address[] accounts, bool[] shouldBeProtected)
Add
accounts
and their protected
attribute. accounts
and shouldBeProtected
must be identical in length and index-matched to each other.claimERC20(address token)
Transfer all the balance of
token
inside TC smart contract to function caller.decreaseAllowance(address spender, uint256 amountToDeduct)
Decrease TC allowance of
spender
by amountToDeduct
.eraseAllApprovals(bool onlyExpired)
Function name uses "Approvals" instead of "Allowances" because its purpose is to delete all information related a given spender on sender's behalf.
increaseAllowance(address spender, uint256 amountToAdd)
Increase TC allowance of
spender
by amountToAdd
.permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s)
permitBurn()
Allows a user to burn the oldest unused and previously-signed message, thereby burning a previous
permit()
--> approve()
they created.rain(uint256 amount, uint256 accountsToRain)
rainAll(uint amount)
rainList(uint256 amount, address[] recipients)
runMyDelegation(address owner, Delegation input)
saveDomainSeparatorAndChainId()
Set
chainId
and DOMAIN_SEPARATOR
.setAdminWallet(address newAdminWallet, bool transferTokens)
Change admin wallet address to
newAdminWallet
. If transferTokens
is true
, transfer all TC tokens inside old adminWallet
to newAdminWallet
. And if old treasuryWallet
was the same as old adminWallet
, reset new treasury wallet as newAdminWallet
.setAllowancePerpetual(address spender, bool enable)
Allow the function caller to decide if they want to enable perpetual approvals for the given
spender
or to delete/disable such setting.setAllowanceTimeToLive(uint newAllowanceTimeToLive)
Allow the function caller to set new
allowanceTimeToLive
.setError(string error, uint256 index)
Admin, treasury or guardian can set error message at
index
of error message list.setGasPerLoop(uint256 newGasPerLoop, uint256 newBreakAtGasThreshold)
Admin, treasury or guardian can set new
gasPerLoop
and breakAtGasThreshold
.setGuardianWallet(address newGuardianWallet)
Admin or treasury can set new
guardianWallet
.setId(address account, uint id)
Admin, treasury or guardian invoke this function to set
id
of account
.setMyDelegation
setProtected(address wallet, bool shouldBeProtected)
Admin, treasury or guardian can allow certain wallets to remain at a static id.
setRainMinimumBalance(uint newRainMinimumBalance)
Admin or treasury can reset rain minimum balance.
setTreasuryWallet(address newTreasuryWallet, bool transferTokens)
Admin or treasury wallet can change treasury wallet.
transferMultiple(address[] recipients, uint[] amounts)
Batch-transfer a list of index-linked recipients and amounts. The lists must be of identical length to avoid unintended transfers.
updateErrorMsg_gasPerLoop()
Privately update the
gasPerLoop
error message.