0x1::STC
STC is the token of Starcoin blockchain.
It uses apis defined in the Token
module.
STC
SharedBurnCapability
initialize
upgrade_from_v1_to_v2
initialize_v2
is_stc
burn
token_address
use 0x1::ConsensusConfig;
use 0x1::CoreAddresses;
use 0x1::Dao;
use 0x1::ModifyDaoConfigProposal;
use 0x1::OnChainConfigDao;
use 0x1::PackageTxnManager;
use 0x1::RewardConfig;
use 0x1::Token;
use 0x1::TransactionPublishOption;
use 0x1::TransactionTimeoutConfig;
use 0x1::Treasury;
use 0x1::UpgradeModuleDaoProposal;
use 0x1::VMConfig;
STC
STC token marker.
struct STC has copy, drop, store
dummy_field: bool
SharedBurnCapability
Burn capability of STC.
struct SharedBurnCapability has store, key
precision of STC token.
const PRECISION: u8 = 9;
initialize
STC initialization.
public fun initialize(account: &signer, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64)
public fun initialize(
account: &signer,
voting_delay: u64,
voting_period: u64,
voting_quorum_rate: u8,
min_action_delay: u64,
) {
Token::register_token<STC>(account, PRECISION);
let burn_cap = Token::remove_burn_capability<STC>(account);
move_to(account, SharedBurnCapability { cap: burn_cap });
Dao::plugin<STC>(
account,
voting_delay,
voting_period,
voting_quorum_rate,
min_action_delay,
);
ModifyDaoConfigProposal::plugin<STC>(account);
let upgrade_plan_cap = PackageTxnManager::extract_submit_upgrade_plan_cap(account);
UpgradeModuleDaoProposal::plugin<STC>(
account,
upgrade_plan_cap,
);
// the following configurations are gov-ed by Dao.
OnChainConfigDao::plugin<STC, TransactionPublishOption::TransactionPublishOption>(account);
OnChainConfigDao::plugin<STC, VMConfig::VMConfig>(account);
OnChainConfigDao::plugin<STC, ConsensusConfig::ConsensusConfig>(account);
OnChainConfigDao::plugin<STC, RewardConfig::RewardConfig>(account);
OnChainConfigDao::plugin<STC, TransactionTimeoutConfig::TransactionTimeoutConfig>(account);
}
include Token::RegisterTokenAbortsIf<STC>{precision: PRECISION};
upgrade_from_v1_to_v2
public fun upgrade_from_v1_to_v2(account: &signer, total_amount: u128): Treasury::WithdrawCapability<STC::STC>
public fun upgrade_from_v1_to_v2(account: &signer,total_amount: u128,): Treasury::WithdrawCapability<STC> {
CoreAddresses::assert_genesis_address(account);
// Mint all stc, and destroy mint capability
let total_stc = Token::mint<STC>(account, total_amount-Token::market_cap<STC>());
let withdraw_cap = Treasury::initialize(account, total_stc);
let mint_cap = Token::remove_mint_capability<STC>(account);
Token::destroy_mint_capability(mint_cap);
withdraw_cap
}
pragma verify = false;
initialize_v2
STC initialization.
public fun initialize_v2(account: &signer, total_amount: u128, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64): Treasury::WithdrawCapability<STC::STC>
public fun initialize_v2(
account: &signer,
total_amount: u128,
voting_delay: u64,
voting_period: u64,
voting_quorum_rate: u8,
min_action_delay: u64,
): Treasury::WithdrawCapability<STC> {
Token::register_token<STC>(account, PRECISION);
// Mint all stc, and destroy mint capability
let total_stc = Token::mint<STC>(account, total_amount);
let withdraw_cap = Treasury::initialize(account, total_stc);
let mint_cap = Token::remove_mint_capability<STC>(account);
Token::destroy_mint_capability(mint_cap);
let burn_cap = Token::remove_burn_capability<STC>(account);
move_to(account, SharedBurnCapability { cap: burn_cap });
Dao::plugin<STC>(
account,
voting_delay,
voting_period,
voting_quorum_rate,
min_action_delay,
);
ModifyDaoConfigProposal::plugin<STC>(account);
let upgrade_plan_cap = PackageTxnManager::extract_submit_upgrade_plan_cap(account);
UpgradeModuleDaoProposal::plugin<STC>(
account,
upgrade_plan_cap,
);
// the following configurations are gov-ed by Dao.
OnChainConfigDao::plugin<STC, TransactionPublishOption::TransactionPublishOption>(account);
OnChainConfigDao::plugin<STC, VMConfig::VMConfig>(account);
OnChainConfigDao::plugin<STC, ConsensusConfig::ConsensusConfig>(account);
OnChainConfigDao::plugin<STC, RewardConfig::RewardConfig>(account);
OnChainConfigDao::plugin<STC, TransactionTimeoutConfig::TransactionTimeoutConfig>(account);
withdraw_cap
}
include Token::RegisterTokenAbortsIf<STC>{precision: PRECISION};
is_stc
Returns true if TokenType
is STC::STC
public fun is_stc<TokenType: store>(): bool
public fun is_stc<TokenType: store>(): bool {
Token::is_same_token<STC, TokenType>()
}
burn
Burn STC tokens. It can be called by anyone.
public fun burn(token: Token::Token<STC::STC>)
public fun burn(token: Token<STC>) acquires SharedBurnCapability {
let cap = borrow_global<SharedBurnCapability>(token_address());
Token::burn_with_capability(&cap.cap, token);
}
aborts_if Token::spec_abstract_total_value<STC>() - token.value < 0;
aborts_if !exists<SharedBurnCapability>(Token::SPEC_TOKEN_TEST_ADDRESS());
token_address
Return STC token address.
public fun token_address(): address
public fun token_address(): address {
Token::token_address<STC>()
}
pragma verify = false;
pragma aborts_if_is_strict = true;