1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- # seahorse
- # Built with Seahorse v0.2.7
- from seahorse.prelude import *
- declare_id('5KCV219sxBAZMfXWP5EZ57D6K9568krgPKGe1Lq2nkxH')
- @instruction
- def create_token(
- mint: Empty[TokenMint],
- signer: Signer
- ):
- mint.init(
- payer = signer,
- decimals = 6,
- authority = signer
- )
- @instruction
- def mint_token(
- mint: TokenMint,
- recipient: TokenAccount,
- signer: Signer,
- amount: u64
- ):
- mint.mint(
- authority = signer,
- to = recipient,
- amount = amount * u64(10) ** u32(mint.decimals)
- )
- @instruction
- def create_associated_token_account(
- token_account: Empty[TokenAccount],
- mint: TokenMint,
- signer: Signer
- ):
- token_account.init(
- associated = True,
- payer = signer,
- mint = mint,
- authority = signer
- )
- @instruction
- def transfer(
- signer_token_account: TokenAccount,
- recipient: TokenAccount,
- signer: Signer,
- amount: u64,
- mint: TokenMint
- ):
- assert signer_token_account.mint() == mint.key(), 'Mint is not the token account mint'
- signer_token_account.transfer(
- authority = signer,
- to = recipient,
- amount = amount * u64(10) ** u32(mint.decimals)
- )
|