EVM Precompiles
Addr

Addr Precompile

Address: 0x0000000000000000000000000000000000001004

This precompile enables EVM clients to query the associated Sei address to an EVM Address and vice versa. For this to work, the addresses must have already been associated on chain.

Association takes place when the wallet first signs and broadcasts any transaction. Some Sei native wallets also provide this feature.

Functions

Transactions

  • associate: Associates an EVM address with it's corresponding Sei native address on chain using a signature. For association via a pubkey, use associatePubKey instead.

      /// Associates an account given it's signature of any custom message.
      /// @param v The v component of the signature.
      /// @param r The r component of the signature.
      /// @param s The s component of the signature.
      /// @param customMessage A custom message that was signed by the address to be associated.
      /// @return Whether the association was successfully executed.
          function associate(
          string memory v,
          string memory r,
          string memory s,
          string memory customMessage
      ) external returns (string memory seiAddr, address evmAddr);

    Example use:

    const message = `This is a test message.`;
     
    // Get the hex encoded signature
    const signature = await signMessageAsync({message})
     
    // Get the v, r, s values
    const { r, s } = secp256k1.Signature.fromCompact(signature.slice(2, 130));
    const v = hexToNumber(`0x${signature.slice(130)}`);
     
    // Append the Ethereum Signed Message prefix to the signed message.
    // This prefix is automatically appended to the message by `sign` methods that use EDCSA, so we need to append this too.
    const messageLength = Buffer.from(message, 'utf8').length;
    const customMessage = `\x19Ethereum Signed Message:\n${messageLength}${message}`;
    const request = {
        r: numberToHex(r),
        s: numberToHex(s),
        v: numberToHex(v - 27),
        custom_message: customMessage
    };
    await contract.associate(request.v, request.r, request.s, request.custom_message)
  • associatePubKey: Enables a user to associate a pair of sei addresses using the public key.

      /// Associates an account given it's compressed pubkey in hex format (excluding the '0x')
      /// @param pubKeyHex The Hex-encoded compressed pubkey of the account to be associated, excluding the '0x'
      /// @return Whether the association was successfully executed.
      function associatePubKey(
          string memory pubKeyHex
      ) external returns (string memory seiAddr, address evmAddr);

    Example use:

    // Create a sample ethers wallet
    const newWallet = ethers.Wallet.createRandom();
    const pkWithout0x = newWallet.publicKey.slice(2)
    await contract.associatePubKey(pkWithout0x)

Queries

  • getSeiAddr: Gets the corresponding Sei Address from the given EVM Address

      /// Queries the corresponding Sei Address for some EVM address.
      /// @param acc The EVM Address for which we want the corresponding Sei address.
      /// @return The corresponding Sei address.
      function getSeiAddr(
          address addr
      ) external view returns (string memory response);
  • getEvmAddr: Gets the corresponding EVM Address from the given Sei Address

      /// Queries the corresponding EVM Address for some Sei address.
      /// @param acc The Sei Address for which we want the corresponding EVM address.
      /// @return The corresponding EVM address.
      function getEvmAddr(
          string memory addr
      ) external view returns (address response);

View the Addr precompile source code and the contract ABI here (opens in a new tab).