Skip to content
Cive

signMessage

Calculates an Ethereum-specific signature in CIP-23 format: keccak256("\x19Conflux Signed Message:\n" + len(message) + message)).

Usage

import { ,  } from "./config";
 
const  = await .({
  ,
  : "hello world",
});
 
Output: "0x7faf17ad6b7e74e4ec5fc47a9845d9cfe260c14b293308f6942ea202588073df4801eb7a2877ccb895bf42d57644c3818eded847bc03edd63fb36574df90699801"
const = await .({ , // Hex data representation of message. : { : "0x68656c6c6f20776f726c64" }, });
Output: "0x7faf17ad6b7e74e4ec5fc47a9845d9cfe260c14b293308f6942ea202588073df4801eb7a2877ccb895bf42d57644c3818eded847bc03edd63fb36574df90699801"

Account Hoisting

If you do not wish to pass an account to every signMessage, you can also hoist the Account on the Wallet Client (see config.ts).

Learn more.

import { walletClient } from "./config";
 
const signature = await walletClient.signMessage({
  message: "hello world",
});
"0x7faf17ad6b7e74e4ec5fc47a9845d9cfe260c14b293308f6942ea202588073df4801eb7a2877ccb895bf42d57644c3818eded847bc03edd63fb36574df90699801"

Returns

Hex

The signed message.

account

  • Type: Account | Address

Account to use for signing.

Accepts a JSON-RPC Account or Local Account (Private Key, etc).

const  = await .({
  : "cfx:...", 
  : "hello world",
});
import {  } from "cive/accounts";
const  = await .({
  : ("0x...", { : . }), 
  : "hello world",
});

message

  • Type: string | { raw: Hex | ByteArray }

Message to sign.

By default, cive signs the UTF-8 representation of the message.

const  = await .({
  : "cfx:...",
  : "hello world", 
});

JSON-RPC Methods

  • JSON-RPC Accounts:
  • Local Accounts
    • Signs locally. No JSON-RPC request.