Skip to main content

signRaw

Callable

  • signRaw(data: string, privateKey: Bytes): SignResult

  • Signs raw data with a given private key without adding the Ethereum-specific prefix.


    Parameters

    • data: string

      The raw data to sign. If it's a hex string, it will be used as-is. Otherwise, it will be UTF-8 encoded.

    • privateKey: Bytes

      The 32 byte private key to sign with

    Returns SignResult

    The signature Object containing the message, messageHash, signature r, s, v

    web3.eth.accounts.signRaw('Some data', '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318')
    > {
    message: 'Some data',
    messageHash: '0x43a26051362b8040b289abe93334a5e3662751aa691185ae9e9a2e1e0c169350',
    v: '0x1b',
    r: '0x93da7e2ddd6b2ff1f5af0c752f052ed0d7d5bff19257db547a69cd9a879b37d4',
    s: '0x334485e42b33815fd2cf8a245a5393b282214060844a9681495df2257140e75c',
    signature: '0x93da7e2ddd6b2ff1f5af0c752f052ed0d7d5bff19257db547a69cd9a879b37d4334485e42b33815fd2cf8a245a5393b282214060844a9681495df2257140e75c1b'
    }