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

Events

PreviousAddress MiningNextBlock Timestamp

Last updated 2 months ago

CtrlK

EVM

event TokenDeployed(address indexed addy);

emit TokenDeployed(addy);

Solana

Regular Emit (Can be dropped from log truncation)

#[event]
pub struct TokenDeployed {
  mint: Pubkey,
}

emit!(TokenDeployed {
  mint: ctx.accounts.mint.key(),
})

CPI Emit (Event logged as a self CPI instruction, does not get dropped)

You first need to turn on the event-cpi feature in Cargo.toml ,

[dependencies]
anchor-lang = { version = "0.31.1", features = ["event-cpi"] }

then

#[event_cpi]
pub struct TokenDeployed {
  mint: Pubkey,
}

emit_cpi!(TokenDeployed {
  mint: ctx.accounts.mint.key(),
})