Skip to main content

Signing

Certain actions – which go to the blockchain – need to be signed by the private key. As described elsewhere, the signer first needs to obtain a challenge:

curl -s -L -X POST "https://cargox.digital/api/v3/blockchain/login-challenge/"

Response:

{ "challenge": "1ZVoa3m5gtZE6veXQQOGKEpRG6M" }

This challenge is then signed using SHA-3 and user's private key. Below are examples in different languages.

The easiest way to sign the message is using the Web3 javascript library.

The following command is used to invoke the private key container (e.g. a hardware wallet, MetaMask or in-memory private key):

web3.eth.personal.sign(
web3.utils.sha3(challenge_string),
accounts[0],
function (e, signature) { ... }
)

You can find a working example of signing a message using a Trezor hardware wallet at their GitHub page.