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

Program Address

PreviousAnchor for EVM DevelopersNextFunctions

Last updated 2 months ago

CtrlK

EVM

  1. Contract address is determined by the deployer's address and nonce (CREATE)

  2. Contract address is determined by the contract's bytecode's hash, deployer's address and a random salt (CREATE2)

function determineAddress(bytes memory bytecode, uint256 salt)
    public
    view
    returns (address)
{
    bytes32 hash = keccak256(
        abi.encodePacked(
            bytes1(0xff), address(deployer), salt, keccak256(bytecode)
        )
    );

    return address(uint160(uint256(hash)));
}

Solana

Program address is determined by a generated private key. It has nothing to do with the deployer address nor the bytecode. The private key for the program is located at target/deploy/$PROGRAM_NAME-keypair.json.