Anchor for EVM Developers
  • Anchor for EVM Developers
  • Program Address
  • Functions
  • Token
  • Validation
  • Mutation
  • Calling Other Contract
  • Wrap Native Token
  • Transfer Native Token
  • Transfer Fungible Token
  • Deploy A Fungible Token
  • Access Control
  • Address Mining
  • Events
  • Forking Mainnet
  • Function Selector
  • Feature Flags
  • Feature Dependencies
  • Migration / Scripts
  • Upgrade Programs
  • Block timestamp
Powered by GitBook
On this page

Wrap Native Token

EVM

IWETH(WETH).deposit{value: msg.value}();
payable(WETH).call{value: msg.value}("");

Solana

  1. Send native SOL to your token account

  2. Call sync_native

#[derive(Accounts)]
pub struct SyncNative<'info> {
    #[account(mut)]
    pub my_token_account: Account<'info, TokenAccount>,
    pub token_program: Program<'info, Token>,
}

pub fn sync_native(ctx: Context<SyncNative>) -> Result<()> {
    sync_native(CpiContext::new(
        ctx.accounts.token_program.to_account_info(),
        SyncNative {
            account: ctx.accounts.my_token_account.to_account_info(),
        },
    ))?;
}

PreviousCalling Other ContractNextTransfer Native Token

Last updated 2 months ago