Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link
Icon AlertTriangle

Mainnet docs are version-pinned. Check each section's exact version in the sidebar; it can lag the newest upstream release.

EVM Address

Icon LinkEvmAddress

In the Rust SDK, Ethereum Virtual Machine (EVM) addresses can be represented with the EvmAddress type. Its definition matches with the Sway standard library type with the same name and will be converted accordingly when interacting with contracts:

pub struct EvmAddress {
    // An evm address is only 20 bytes, the first 12 bytes should be set to 0
    value: Bits256,
}

Here's an example:

let b256 = Bits256::from_hex_str(
    "0x1616060606060606060606060606060606060606060606060606060606060606",
)?;
let evm_address = EvmAddress::from(b256);
 
let call_handler = contract_instance
    .methods()
    .evm_address_as_input(evm_address);
Icon InfoCircle

Note: when creating an EvmAddress from Bits256, the first 12 bytes will be cleared because an EVM address is only 20 bytes long.