~/bend-docscommunity

sol.bend relies on unsafe/foreign

raw source on the hub · import 0x38c59765d1dfcdb7e4b4aa026bafb649/sol.bend as Sol

2 imports
import Base
import ./types.bend as Ty

Types

type Cpi source · line 448 · raw

Data

type Context source · line 668 · raw

Data

type Outcome source · line 677 · raw

Data

type Attempt source · line 718 · raw

@-a:Quant -> @-A:Kind(a) -> Kind(a)

One require in a do Try<>: block. No carries the error; Yes carries the value.

Definitions

def key source · line 9 · raw

@a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey

def owner source · line 14 · raw

@a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey

def is_signer source · line 19 · raw

@a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> Bool

def is_writable source · line 24 · raw

@a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> Bool

def lamports source · line 29 · raw

@a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def data source · line 34 · raw

@a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> List<&2, U32>

def set_data source · line 39 · raw

@a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> @bytes:List<&2, U32> -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account

def set_lamports source · line 44 · raw

@a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> @lams:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account

def add_lamports source · line 49 · raw

@+a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> @amt:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account

def sub_lamports source · line 52 · raw

@+a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> @amt:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account

def is_owned_by source · line 55 · raw

@+a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> @+program_id:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> Bool

def system_id source · line 59 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey

The all-zero pubkey is the System program.

def is_system source · line 63 · raw

@+a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> Bool

Key is the System program.

def is_signer_of source · line 67 · raw

@is_signer:Bool -> @same:Bool -> Bool

Signer flag and key comparison both hold.

def empty_account source · line 71 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account

Placeholder for an account index past the end of the list.

def get_u32 source · line 85 · raw

@xs:List<&2, U32> -> @i:Nat -> U32

Word i, or 0 when i is past the end.

def set_u32 source · line 95 · raw

@xs:List<&2, U32> -> @i:Nat -> @v:U32 -> List<&2, U32>

Replace word i. An index past the end leaves the list unchanged.

def data_len source · line 104 · raw

@xs:List<&2, U32> -> Nat

def has_words source · line 111 · raw

@xs:List<&2, U32> -> @n:Nat -> Bool

def as_bytes source · line 116 · raw

@xs:List<&2, U32> -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Slice

A byte slice into a word buffer. off and len are bytes. Ty.Account fields use this so a bump is one byte, not a u32 word.

def slice source · line 119 · raw

@s:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Slice -> @off:Nat -> @len:Nat -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Slice

def slice_len source · line 124 · raw

@s:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Slice -> U32

def byte_index source · line 129 · raw

@+off:U32 -> @+i:Nat -> U32

def word_index source · line 132 · raw

@+i:U32 -> Nat

def byte_shift source · line 135 · raw

@+i:U32 -> U32

def get_u8 source · line 138 · raw

@s:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Slice -> @+i:Nat -> U32

def has_discriminator source · line 150 · raw

@xs:List<&2, U32> -> @d:U32 -> Bool

Byte 0 equals d. An empty buffer compares as 0.

def set_u8 source · line 153 · raw

@+xs:List<&2, U32> -> @+i:Nat -> @+v:U32 -> List<&2, U32>

def le_u32 source · line 166 · raw

@+s:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Slice -> @+i:Nat -> U32

def set_le_u32 source · line 172 · raw

@+xs:List<&2, U32> -> @+i:Nat -> @+v:U32 -> List<&2, U32>

def le_u64 source · line 183 · raw

@+s:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Slice -> @+i:Nat -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def as_word source · line 186 · raw

@v:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u32 -> U32

def set_le_u64 source · line 189 · raw

@+xs:List<&2, U32> -> @+i:Nat -> @+v:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> List<&2, U32>

def pubkey_at source · line 196 · raw

@+s:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Slice -> @+i:Nat -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey

def set_pubkey_at source · line 208 · raw

@+xs:List<&2, U32> -> @+i:Nat -> @+k:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> List<&2, U32>

def eq_pubkey source · line 238 · raw

@+xs:List<&2, U32> -> @+off:Nat -> @+k:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> Bool

Stored pubkey at byte off equals k.

def get_u32_word source · line 242 · raw

@xs:List<&2, U32> -> @i:Nat -> U32

Same as get_u32.

def set_u32_word source · line 246 · raw

@xs:List<&2, U32> -> @i:Nat -> @v:U32 -> List<&2, U32>

Same as set_u32.

def get_u64 source · line 250 · raw

@+xs:List<&2, U32> -> @+i:Nat -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

Little-endian u64 at words i and i+1.

def set_u64 source · line 254 · raw

@+xs:List<&2, U32> -> @+i:Nat -> @+v:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> List<&2, U32>

Write a little-endian u64 at words i and i+1.

def zeros source · line 258 · raw

@n:Nat -> List<&2, U32>

n zero words. Used to pad a short account before the first write.

def ensure_if source · line 266 · raw

@ok:Bool -> @xs:List<&2, U32> -> @n:Nat -> List<&2, U32>

Keep xs when it is already long enough; otherwise n zero words.

def ensure_words source · line 274 · raw

@+xs:List<&2, U32> -> @+n:Nat -> List<&2, U32>

Pad with zeros when xs is shorter than n words.

def resize source · line 278 · raw

@+xs:List<&2, U32> -> @+n:Nat -> List<&2, U32>

Lengthen a word view by at most 10240 bytes. The compiler emits list_grow.

def get_pubkey source · line 282 · raw

@+xs:List<&2, U32> -> @+off:Nat -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey

Ty.Pubkey at word offset off (eight words).

def set_pubkey source · line 295 · raw

@xs:List<&2, U32> -> @+off:Nat -> @p:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> List<&2, U32>

Write eight pubkey words at off.

def keys_eq source · line 325 · raw

@+xs:List<&2, U32> -> @+off:Nat -> @+k:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> Bool

Ty.Pubkey at word offset off equals k.

def keys_eq_words source · line 329 · raw

@+a:List<&2, U32> -> @+ao:Nat -> @+b:List<&2, U32> -> @+bo:Nat -> Bool

The pubkey at ao in a equals the pubkey at bo in b.

def pda_matches source · line 338 · raw

@+got:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+want:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> Bool

Byte equality. Address derivation is is_program_address, not this.

def seeds_nil source · line 343 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds

Ordered seeds for find_program_address. At most 16, each 1..=32 bytes. The book mark is not the hash. is_program_address / find_program_address are the natives.

def seeds_push source · line 348 · raw

@+ss:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds -> @+bytes:List<&2, U32> -> @nbytes:U32 -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds

Append nbytes of bytes (little-endian words). The chain copies those bytes; this body only keeps the checker from dropping the arguments.

def seed_str source · line 355 · raw

@+ss:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds -> @+text:String -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds

Append the bytes of a constant string. The book mark ignores the text. The compiler native copies those bytes.

def seed_pk source · line 361 · raw

@+ss:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds -> @+k:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds

Thirty-two bytes of a pubkey.

def is_program_address source · line 365 · raw

@+got:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+program_id:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+seeds:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds -> Bool

Checker dummy. Compiler native is find_program_address(seeds, program_id).

def is_program_address_pk source · line 383 · raw

@+got:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+program_id:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+owner:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> Bool

Address is the PDA whose only seed is owner. find_program_address.

def is_program_address_bump source · line 391 · raw

@+got:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+program_id:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+seeds:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds -> @+bump:U32 -> Bool

Checker dummy. Compiler native is create_program_address(seeds, bump).

def is_program_address_pk_bump source · line 411 · raw

@+got:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+program_id:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+owner:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+bump:U32 -> Bool

got is create_program_address([owner, bump]).

def rent_exempt source · line 421 · raw

@+bytes:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

Checker dummy. The compiler native reads the Rent sysvar: (bytes + 128) * lamports_per_byte_year * exemption_threshold.

def rent_due_go source · line 424 · raw

@fits:Bool -> @+have:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @+need:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def rent_due source · line 432 · raw

@+have:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @+need:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

Extra lamports to raise an account from have bytes to need bytes.

def find_program_address source · line 436 · raw

@+program_id:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+seeds:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds -> U32

Checker dummy bump 255. Compiler native is the try_find bump.

def find_program_address_pk source · line 442 · raw

@+program_id:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+owner:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> U32

find_program_address bump for an owner-only PDA.

def cpi_none source · line 539 · raw

Cpi

def cpi_is_none source · line 542 · raw

@c:Cpi -> Bool

def cpi_head source · line 574 · raw

@xs:List<&2, Cpi> -> Cpi

First queued CPI, or CpiNone when the queue is empty.

def cpi_at source · line 582 · raw

@xs:List<&2, Cpi> -> @i:Nat -> Cpi

CPI at index i, or CpiNone when i is past the end.

def cpi_put source · line 592 · raw

@xs:List<&2, Cpi> -> @c:Cpi -> List<&2, Cpi>

Replace a leading CpiNone; otherwise append. Empty (Nil) becomes a singleton.

def MAX_ACCOUNTS source · line 665 · raw

U32

Runtime cap. The book list is unbounded; the runtime rejects more.

def ok source · line 681 · raw

@+c:Context -> Outcome

def fail source · line 684 · raw

@+code:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Outcome

def err_is source · line 688 · raw

@outcome:Outcome -> @want:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Bool

The outcome is Err{want}. An Ok outcome is False.

def is_ok source · line 696 · raw

@outcome:Outcome -> Bool

The outcome is Ok. An Err outcome is False.

def wrote source · line 705 · raw

@outcome:Outcome -> @want:Context -> Bool

Ok{want}, field for field. Any other outcome is False. The two contexts must be the same term: same accounts, instruction, and queue.

def Try.bind source · line 723 · raw

@-A:Data -> @m:Attempt<&2, A> -> @next:(@_:A -> Outcome) -> Outcome

do Try<>: runs each require in order. False, or None, is Err{code}.

def Try.pure source · line 731 · raw

@o:Outcome -> Outcome

return in a do Try<>: block.

def require source · line 735 · raw

@ok:Bool -> @+code:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Attempt<&2, Unit>

False is No{code}. True is Yes{Unit}, so the next line runs.

def require_some source · line 743 · raw

@m:Maybe<&2, U32> -> @+code:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Attempt<&2, U32>

None is No{code}. Some is Yes of the U32, bound by name: U32 <-.

def require_u64 source · line 751 · raw

@m:Maybe<&2, 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64> -> @+code:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Attempt<&2, 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64>

None is No{code}. Some is Yes of the Ty.u64, bound by name: Ty.u64 <-.

def Err.ok source · line 761 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

Solana program-error returns. Builtin variants are hi << 32. custom is ProgramError::Custom: the low word, for a code with no standard variant. Custom(0) is not a failure; pass a non-zero code.

def Err.not_enough_account_keys source · line 764 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def Err.invalid_instruction_data source · line 767 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def Err.invalid_account_data source · line 770 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def Err.insufficient_funds source · line 773 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def Err.account_already_initialized source · line 776 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def Err.uninitialized_account source · line 779 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def Err.invalid_seeds source · line 782 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def Err.illegal_owner source · line 785 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def Err.arithmetic_overflow source · line 788 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def Err.incorrect_authority source · line 791 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def Err.custom source · line 794 · raw

@code:U32 -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def account_at source · line 798 · raw

@xs:List<&2, 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account> -> @i:Nat -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account

Ty.Account i, or the empty account when i is past the end.

def set_accounts source · line 808 · raw

@xs:List<&2, 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account> -> @i:Nat -> @a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> List<&2, 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account>

Replace account i. An index past the end leaves the list unchanged.

def instruction_data source · line 821 · raw

@c:Context -> List<&2, U32>

def ix_u32 source · line 826 · raw

@c:Context -> @i:Nat -> U32

def ix_u8 source · line 832 · raw

@c:Context -> @i:Nat -> U32

Instruction discriminator. Byte i of the instruction data, widened to U32.

def ix_u64 source · line 838 · raw

@c:Context -> @i:Nat -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

Little-endian u64 at byte offset i. Byte 0 is the discriminator.

def accounts source · line 843 · raw

@c:Context -> List<&2, 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account>

def account source · line 848 · raw

@c:Context -> @i:Nat -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account

def cpi_queue source · line 853 · raw

@c:Context -> List<&2, Cpi>

def accounts_len source · line 858 · raw

@c:Context -> U32

def program_id source · line 863 · raw

@c:Context -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey

def cpi source · line 869 · raw

@c:Context -> Cpi

Head of the CPI queue.

def cpi1 source · line 875 · raw

@c:Context -> Cpi

Second queued CPI.

def set_account source · line 880 · raw

@c:Context -> @i:Nat -> @a:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Account -> Context

def context_set_cpis source · line 885 · raw

@c:Context -> @cpis:List<&2, Cpi> -> Context

def cpi_push source · line 891 · raw

@+c:Context -> @cpi:Cpi -> Context

Append a CPI, replacing a leading CpiNone.

def set_cpi source · line 895 · raw

@c:Context -> @cpi:Cpi -> Context

Append. Does not overwrite a fixed slot.

def set_cpi1 source · line 899 · raw

@c:Context -> @cpi1:Cpi -> Context

Append, same as set_cpi.

def invoke source · line 905 · raw

@+c:Context -> @+program:U32 -> @+accs:List<&2, U32> -> @+ix:List<&2, U32> -> Context

Queue an unsigned invoke. program and accs are account indexes. ix is instruction data as u32 words. Signer and writable flags are the ones on those accounts. The callee runs after this handler returns Ok.

def invoke_signed_seeds source · line 914 · raw

@+c:Context -> @+program:U32 -> @+accs:List<&2, U32> -> @+ix:List<&2, U32> -> @+auth:U32 -> @+bump:U32 -> @+seeds:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds -> Context

Queue an invoke signed by seeds plus bump. The book seed word stays 0.

def Sys.transfer source · line 931 · raw

@+c:Context -> @+from:U32 -> @+to:U32 -> @+lamports:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Context

Queue an unsigned System transfer. from and to are account indexes.

def Sys.transfer_signed_seeds source · line 941 · raw

@+c:Context -> @+from:U32 -> @+to:U32 -> @+lamports:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @+bump:U32 -> @+seeds:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds -> Context

Queue a System transfer signed by seeds plus bump. The chain signer is that list. The book Cpi seed word stays 0.

def Token.transfer source · line 957 · raw

@+c:Context -> @+from:U32 -> @+to:U32 -> @+mint:U32 -> @+auth:U32 -> @+amount:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @+decimals:U32 -> Context

Queue an unsigned SPL Token TransferChecked. Indexes are account slots.

def Token.transfer_signed_seeds source · line 972 · raw

@+c:Context -> @+from:U32 -> @+to:U32 -> @+mint:U32 -> @+auth:U32 -> @+amount:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @+decimals:U32 -> @+bump:U32 -> @+seeds:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds -> Context

Queue a TransferChecked signed by seeds plus bump.

def Sys.create_account source · line 1003 · raw

@+c:Context -> @+payer:U32 -> @+new:U32 -> @+lamports:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @+space:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @+sign:Bool -> @+bump:U32 -> @+seeds:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds -> Context

Queue a System CreateAccount. payer funds new. When sign, seeds plus bump sign the new account. Owner is this program.

def Sys.assign source · line 1021 · raw

@+c:Context -> @+account:U32 -> @+owner:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> Context

Queue a System Assign. account is the index; owner is the new owner.

def Sys.assign_signed_seeds source · line 1025 · raw

@+c:Context -> @+account:U32 -> @+owner:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+bump:U32 -> @+seeds:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds -> Context

Queue a System Assign signed by seeds plus bump.

def Sys.allocate source · line 1037 · raw

@+c:Context -> @+account:U32 -> @+space:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Context

Queue a System Allocate. account is the index; space is the byte length.

def Sys.allocate_signed_seeds source · line 1041 · raw

@+c:Context -> @+account:U32 -> @+space:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @+bump:U32 -> @+seeds:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Seeds -> Context

Queue a System Allocate signed by seeds plus bump.

def Token.approve source · line 1056 · raw

@+c:Context -> @+from:U32 -> @+to:U32 -> @+auth:U32 -> @+amount:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Context

SPL Token Approve (disc 4). from source, to delegate, auth owner.

def Token.revoke source · line 1069 · raw

@+c:Context -> @+from:U32 -> @+auth:U32 -> Context

SPL Token Revoke (disc 5).

def Token.mint_to source · line 1087 · raw

@+c:Context -> @+from:U32 -> @+to:U32 -> @+auth:U32 -> @+amount:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Context

SPL Token MintTo (disc 7). from mint, to destination, auth mint authority.

def Token.freeze source · line 1100 · raw

@+c:Context -> @+from:U32 -> @+to:U32 -> @+auth:U32 -> Context

SPL Token FreezeAccount (disc 10). from account, to mint, auth freeze authority.

def Token.thaw source · line 1118 · raw

@+c:Context -> @+from:U32 -> @+to:U32 -> @+auth:U32 -> Context

SPL Token ThawAccount (disc 11).

def Token.initialize_mint source · line 1136 · raw

@+c:Context -> @+from:U32 -> @+decimals:U32 -> @+owner:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> Context

SPL Token InitializeMint2 (disc 20). from is the mint. owner is mint+freeze authority.

def Token.initialize_account source · line 1148 · raw

@+c:Context -> @+from:U32 -> @+to:U32 -> @+owner:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> Context

SPL Token InitializeAccount3 (disc 18). from account, to mint, owner token owner.

def ATA.id source · line 1160 · raw

0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey

Associated Token Ty.Account program id (ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL).

def ATA.address source · line 1173 · raw

@+wallet:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+mint:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey

Derive the ATA address for wallet + mint (Tokenkeg). Native on chain.

def ATA.create source · line 1177 · raw

@+c:Context -> @+payer:U32 -> @+ata:U32 -> @+wallet:U32 -> @+mint:U32 -> @+system:U32 -> @+token:U32 -> Context

Queue ATA Create (disc 0).

def ATA.create_idempotent source · line 1189 · raw

@+c:Context -> @+payer:U32 -> @+ata:U32 -> @+wallet:U32 -> @+mint:U32 -> @+system:U32 -> @+token:U32 -> Context

Queue ATA CreateIdempotent (disc 1).

def require_accounts source · line 1201 · raw

@c:Context -> @k:U32 -> Bool

accounts_len is at least k.

def counter_inc source · line 1206 · raw

@+value:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

Checked arithmetic and small masks used by the examples. counter_inc wraps; the checked ones return None on failure.

def dec_if source · line 1210 · raw

@z:Bool -> @value:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Maybe<&2, 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64>

None when z (the value is already 0).

def counter_dec source · line 1218 · raw

@+value:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Maybe<&2, 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64>

value - 1, or None at 0.

def withdraw_if source · line 1222 · raw

@lt:Bool -> @bal:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @amt:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Maybe<&2, 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64>

None when lt (bal < amt).

def try_withdraw source · line 1230 · raw

@+bal:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @+amt:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Maybe<&2, 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64>

bal - amt, or None when amt exceeds bal.

def deposit_if source · line 1234 · raw

@ovf:Bool -> @bal:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @amt:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Maybe<&2, 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64>

None when ovf (the add would wrap).

def try_deposit source · line 1242 · raw

@+bal:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @+amt:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Maybe<&2, 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64>

bal + amt, or None on overflow.

def popcount.go source · line 1246 · raw

@fuel:Nat -> @+mask:U32 -> @acc:U32 -> U32

Count set bits, one shift per fuel step. fuel 0 returns acc.

def popcount source · line 1254 · raw

@mask:U32 -> U32

Number of set bits in mask.

def bit_set source · line 1258 · raw

@mask:U32 -> @i:U32 -> U32

Set bit i in one U32 half of a mask.

def bit_set_u64 source · line 1262 · raw

@+mask:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @+i:U32 -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

Set bit i of a u64 mask.

def popcount_u64.go source · line 1265 · raw

@fuel:Nat -> @+mask:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @acc:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

def popcount_u64 source · line 1277 · raw

@+mask:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> 0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64

Number of set bits in a u64 mask.

def can_execute source · line 1281 · raw

@+approvals:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> @+threshold:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Bool

At least threshold bits are set in the approval mask.

def pick_u32 source · line 1285 · raw

@b:Bool -> @t:U32 -> @f:U32 -> U32

t when b, otherwise f.

def maybe_u32 source · line 1293 · raw

@b:Bool -> @v:U32 -> Maybe<&2, U32>

Some{v} when b, otherwise None.

def owner_pick source · line 1301 · raw

@is0:Bool -> @is1:Bool -> Maybe<&2, U32>

Some{0} if is0, else Some{1} if is1, else None.

def owner_index source · line 1309 · raw

@+pk:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+o0:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+o1:0x38c59765d1dfcdb7e4b4aa026bafb649/types.Pubkey -> @+n:0x38c59765d1dfcdb7e4b4aa026bafb649/types.u64 -> Maybe<&2, U32>

Index of key among the first n owners, or None.