#[provable]
pub fn example_token_policy(
app_id: AppId,
tx: Transaction,
x: Data,
#[private] w: Data,
) {
assert_eq!(app_id.tag, TOKEN);
let in_amount = sum_token_amount(&app_id, &tx.ins);
let out_amount = sum_token_amount(&app_id, &tx.outs);
if in_amount != out_amount {
// enforce token mint/burn policy based on the transaction,
// public and private witness data
assert!(can_mint_or_burn(&app_id, &tx, &x, &w))
}
}
basic structure of a token implementation
#[provable]
pub fn example_nft(
app_id: AppId,
tx: Transaction,
x: Data,
#[private] w: Data,
) {
assert_eq!(app_id.tag, NFT);
// if the NFT state is unchanged (it was simply transferred),
// no need to check if we can update the state
if !nft_state_preserved(&app_id, &tx) {
assert!(can_update_nft_state(&app_id, &tx, &x, &w))
}
}
basic structure of NFT implementation
existing token standards on Bitcoin are not (easily) programmable
you can't (easily) lock Bitcoin, so that it could be unlocked by satisfying external logic
with these problems solved, the market for Bitcoin based tokens will quickly grow ~100x
(it is now ~$1b)