sign

suspend fun sign(apiKey: String, chainId: String, curve: PortalCurve, message: PortalSignRequest, rpcUrl: String): String

Signs a transaction or message using the MPC (Multi-Party Computation) protocol.

This function interacts with an MPC service to perform a signature operation. It takes in necessary details like API key, chain ID, elliptic curve type, message to sign, and RPC URL. It internally fetches a signing share from the keychain, builds the payload for the MPC service, and then calls the service to perform the signing.

Return

The resulting signature as a String.

Parameters

apiKey

The API key used for authenticating with the MPC service.

chainId

The ID of the blockchain network to which the transaction or message pertains.

curve

The elliptic curve used for signing (e.g., secp256k1).

message

A PortalSignRequest object containing the method and parameters for signing. The structure of this parameter will dictate what operation needs to be performed, it can contain a message to sign or details about the transaction to sign.

rpcUrl

The RPC endpoint URL for interacting with the blockchain network.

Throws

If the MPC service returns an error.

If any other unexpected error occurs during the process, including JSON parsing errors.