Skip to main content

createContractAddress

Callable

  • createContractAddress(from: string, nonce: Numbers): string

  • Generates the Ethereum address of a contract created via a regular transaction.

    This function calculates the contract address based on the sender's address and nonce, following Ethereum's address generation rules.

    @throws

    An InvalidAddressError if the provided address ('from') is invalid.

    @throws

    An InvalidNumberError if the provided nonce value is not in a valid format.

    @example
    const from = "0x1234567890abcdef1234567890abcdef12345678";
    const nonce = (await web3.eth.getTransactionCount(from)) + 1; // The nonce value for the transaction

    const res = createContractAddress(from, nonce);

    console.log(res);
    // > "0x604f1ECbA68f4B4Da57D49C2b945A75bAb331208"

    Parameters

    Returns string

    An Ethereum Address of the contract in checksum address format.