relay_depository
program
RelayDepository
relay_depository
initialize
ctx
- The context containing the accountsOk(())
on successset_allocator
ctx
- The context containing the accountsnew_allocator
- The public key of the new allocatorOk(())
on successErr(error)
if not authorizedset_owner
ctx
- The context containing the accountsnew_owner
- The public key of the new ownerOk(())
on successErr(error)
if not authorizeddeposit_native
ctx
- The context containing the accountsamount
- The amount of SOL to depositid
- A unique identifier for the depositOk(())
on successdeposit_token
ctx
- The context containing the accountsamount
- The amount of tokens to depositid
- A unique identifier for the depositOk(())
on successexecute_transfer
ctx
- The context containing the accountsrequest
- The transfer request details and signatureOk(())
on successErr(error)
if signature is invalid or request can’t be processedinstruction
#[program]
mod is
associated with a struct defining the input arguments to the
method. These should be used directly, when one wants to serialize
Anchor instruction data, for example, when speciying
instructions on a client.
Initialize
SetAllocator
Name | Type | Documentation |
---|---|---|
new_allocator | Pubkey |
SetOwner
Name | Type | Documentation |
---|---|---|
new_owner | Pubkey |
DepositNative
Name | Type | Documentation |
---|---|---|
amount | u64 | |
id | [u8; 32] |
DepositToken
Name | Type | Documentation |
---|---|---|
amount | u64 | |
id | [u8; 32] |
ExecuteTransfer
Name | Type | Documentation |
---|---|---|
request | TransferRequest |
cpi
#[<cfg>(feature = "cpi")]
accounts
Accounts
, where each field is
an AccountInfo
. This is useful for CPI.
crate::__cpi_client_accounts_set_allocator::*
crate::__cpi_client_accounts_set_owner::*
crate::__cpi_client_accounts_initialize::*
crate::__cpi_client_accounts_deposit_token::*
crate::__cpi_client_accounts_execute_transfer::*
crate::__cpi_client_accounts_deposit_native::*
Return
Name | Type | Documentation |
---|---|---|
private fields | … | Some fields have been omitted |
initialize
set_allocator
set_owner
deposit_native
deposit_token
execute_transfer
accounts
Accounts
, where each field is
a Pubkey
. This is useful for specifying accounts for a client.
crate::__client_accounts_execute_transfer::*
crate::__client_accounts_deposit_token::*
crate::__client_accounts_initialize::*
crate::__client_accounts_set_owner::*
crate::__client_accounts_set_allocator::*
crate::__client_accounts_deposit_native::*
RelayDepository
RELAY_DEPOSITORY_SEED
and
contains the ownership and allocation information.
Name | Type | Documentation |
---|---|---|
owner | Pubkey | The owner of the relay depository who can update settings |
allocator | Pubkey | The authorized allocator that can sign transfer requests |
vault_bump | u8 | The bump seed for the vault PDA, used for deriving the vault address |
UsedRequest
Name | Type | Documentation |
---|---|---|
is_used | bool | Flag indicating whether the request has been processed |
Initialize
Name | Type | Documentation |
---|---|---|
relay_depository | Account<''info, RelayDepository> | The relay depository account to be initialized This is a PDA derived from the RELAY_DEPOSITORY_SEED |
vault | UncheckedAccount<''info> | PDA that will hold SOL deposits CHECK: This is a PDA derived from the VAULT_SEED |
owner | Signer<''info> | The owner account that pays for initialization Must match the AUTHORIZED_PUBKEY |
allocator | UncheckedAccount<''info> | The allocator account that will be authorized to sign transfer requests CHECK: Used as public key only |
system_program | Program<''info, System> |
InitializeBumps
Name | Type | Documentation |
---|---|---|
relay_depository | u8 | |
vault | u8 |
SetAllocator
Name | Type | Documentation |
---|---|---|
relay_depository | Account<''info, RelayDepository> | The relay depository account to update |
owner | Signer<''info> | The owner of the relay depository |
SetAllocatorBumps
Name | Type | Documentation |
---|---|---|
relay_depository | u8 |
SetOwner
Name | Type | Documentation |
---|---|---|
relay_depository | Account<''info, RelayDepository> | The relay depository account to update |
owner | Signer<''info> | The current owner of the relay depository |
SetOwnerBumps
Name | Type | Documentation |
---|---|---|
relay_depository | u8 |
DepositNative
Name | Type | Documentation |
---|---|---|
relay_depository | Account<''info, RelayDepository> | The relay depository account |
sender | Signer<''info> | The sender of the deposit |
depositor | UncheckedAccount<''info> | The account credited for the deposit CHECK: The account credited for the deposit |
vault | UncheckedAccount<''info> | The vault PDA that will receive the SOL CHECK: The vault PDA that will receive the SOL |
system_program | Program<''info, System> | The system program |
DepositNativeBumps
Name | Type | Documentation |
---|---|---|
relay_depository | u8 |
DepositToken
Name | Type | Documentation |
---|---|---|
relay_depository | Account<''info, RelayDepository> | The relay depository account |
sender | Signer<''info> | The sender of the deposit |
depositor | UncheckedAccount<''info> | The account credited for the deposit CHECK: The account credited for the deposit |
vault | UncheckedAccount<''info> | The vault PDA that will receive the tokens CHECK: The vault PDA that will receive the tokens |
mint | InterfaceAccount<''info, anchor_spl::token_interface::Mint> | The mint of the token being deposited |
sender_token_account | InterfaceAccount<''info, anchor_spl::token_interface::TokenAccount> | The sender’s token account |
vault_token_account | UncheckedAccount<''info> | CHECK: The vault’s token account |
token_program | Interface<''info, anchor_spl::token_interface::TokenInterface> | The token program |
associated_token_program | Program<''info, anchor_spl::associated_token::AssociatedToken> | The associated token program |
system_program | Program<''info, System> | The system program |
DepositTokenBumps
Name | Type | Documentation |
---|---|---|
relay_depository | u8 |
ExecuteTransfer
#[instruction(request: TransferRequest)]
Name | Type | Documentation |
---|---|---|
relay_depository | Account<''info, RelayDepository> | The relay depository account CHECK: The relay depository account |
executor | Signer<''info> | The executor of the transfer CHECK: The executor of the transfer |
recipient | UncheckedAccount<''info> | The recipient of the transfer CHECK: The recipient of the transfer |
vault | UncheckedAccount<''info> | The vault PDA that will receive the tokens CHECK: The vault PDA that will receive the tokens |
mint | Option<InterfaceAccount<''info, anchor_spl::token_interface::Mint>> | The mint of the token being transferred |
recipient_token_account | Option<InterfaceAccount<''info, anchor_spl::token_interface::TokenAccount>> | The recipient’s token account |
vault_token_account | Option<InterfaceAccount<''info, anchor_spl::token_interface::TokenAccount>> | The vault’s token account |
used_request | Account<''info, UsedRequest> | The account that tracks whether a transfer request has been used This account is created for each transfer request to prevent replay attacks. |
ix_sysvar | AccountInfo<''info> | The instruction sysvar for ed25519 verification CHECK: The instruction sysvar for ed25519 verification |
token_program | Interface<''info, anchor_spl::token_interface::TokenInterface> | The token program |
associated_token_program | Program<''info, anchor_spl::associated_token::AssociatedToken> | The associated token program |
system_program | Program<''info, System> | The system program |
ExecuteTransferBumps
Name | Type | Documentation |
---|---|---|
relay_depository | u8 | |
used_request | u8 |
TransferRequest
Name | Type | Documentation |
---|---|---|
recipient | Pubkey | The recipient of the transfer |
token | Option<Pubkey> | The token mint (None for native SOL, Some(mint) for SPL tokens) |
amount | u64 | The amount to transfer |
nonce | u64 | A unique nonce |
expiration | i64 | The expiration timestamp for the request |
TransferExecutedEvent
Name | Type | Documentation |
---|---|---|
request | TransferRequest | The transfer request that was executed |
executor | Pubkey | The public key of the executor who processed the transfer |
id | Pubkey | The unique identifier for the used request account |
DepositEvent
Name | Type | Documentation |
---|---|---|
depositor | Pubkey | The public key of the depositor |
token | Option<Pubkey> | The token mint (None for native SOL, Some(mint) for SPL tokens) |
amount | u64 | The amount deposited |
id | [u8; 32] | A unique identifier for the deposit |
CustomError
#[repr(u32)]
TransferRequestAlreadyUsed
InvalidMint
Unauthorized
AllocatorSignerMismatch
MessageMismatch
MalformedEd25519Data
MissingSignature
SignatureExpired
InvalidRecipient
InvalidVaultTokenAccount
InsufficientVaultBalance
check_id
id
id_const
ID
entry
#[program]
module in a way similar
to writing RPC request handlers. The macro then generates a bunch of
code wrapping these user defined methods into something that can be
executed on Solana.
These methods fall into one category for now.
Global methods - regular methods inside of the #[program]
.
Care must be taken by the codegen to prevent collisions between
methods in these different namespaces. For this reason, Anchor uses
a variant of sighash to perform method dispatch, rather than
something like a simple enum variant discriminator.
The execution flow of the generated code can be roughly outlined:
anchor_lang
for details.#[program]
module. Perform method dispatch, i.e., execute the
big match statement mapping method identifier to method handler
wrapper.entry
function here, defines the standard entry to a Solana
program, where execution begins.
get_transfer_fee
mint_account
- The mint account of the tokenpre_fee_amount
- The amount to transfer before feesID
ID_CONST
ID