API Usage with Curl

Using Curl to interact with Signchain’s API is a straightforward way to make requests to the self-hosted or hosted vault. This guide covers common API requests for creating, retrieving, and managing wallets, as well as signing transactions.

Prerequisites

To follow along, ensure you have:

  • An API key and Vault ID, available from your Signchain Dashboard.
  • Curl installed on your local environment.

Base URL

The base URL for all requests is https://signchain.net/api/v1. We route requests to your self-hosted vault through our API, so you don't need to update the URL.

You can use the Signchain Hosted Vault ID for all requests if that's the mechanism you'd prefer to get started with.


Basic Authentication

To authorize requests, include the API key in the Authorization header.

Example format:

-H "Authorization: Bearer <your-api-key>"

Creating a Wallet

To create a new wallet in your vault:

curl -X POST https://signchain.net/api/v1/vaults/<vault-id>/wallets \
     -H "Authorization: Bearer <your-api-key>" \
     -H "Content-Type: application/json" \
     -d '{"name": "My Wallet"}'

Response

A successful request returns a JSON object with details about the new wallet, including its unique ID, address, and metadata.


Listing Wallets

To list all wallets within a vault:

curl -X GET https://signchain.net/api/v1/vaults/<vault-id>/wallets \
     -H "Authorization: Bearer <your-api-key>"

This endpoint returns an array of wallet objects, with each containing its unique ID, address, and metadata.


Retrieving a Wallet

To get details of a specific wallet:

curl -X GET https://signchain.net/api/v1/vaults/<vault-id>/wallets/<wallet-address> \
     -H "Authorization: Bearer <your-api-key>"

Replace <wallet-address> with the wallet’s address. This request returns detailed information about the specified wallet.


Signing a Transaction

To sign a transaction with Signchain’s vault:

curl -X POST https://signchain.net/api/v1/vaults/<vault-id>/sign \
     -H "Authorization: Bearer <your-api-key>" \
     -H "Content-Type: application/json" \
     -d '{
           "contract": "<contract-address>",
           "chain": "ethereum",
           "sender": "<sender-address>",
           "abi": {"name": "myFunction", "inputs": [...], "outputs": [...]},
           "args": ["<arg1>", "<arg2>"]
         }'

Replace placeholders with the actual values:

  • contract: The address of the target smart contract.
  • chain: Specify the chain (ethereum, bsc, etc.).
  • sender: The address of the account initiating the transaction.
  • abi: An object containing the contract function's ABI details. An ABI is an array of such objects, only the function which you are targetting should be supplied.
  • args: Arguments to pass to the function.

Response

If successful, the request returns a JSON object containing the signature along with the arguments you passed in, allowing for secure transaction submission.


Updating a Wallet

To update a wallet’s details (e.g., name):

curl -X PUT https://signchain.net/api/v1/vaults/<vault-id>/wallets/<wallet-address> \
     -H "Authorization: Bearer <your-api-key>" \
     -H "Content-Type: application/json" \
     -d '{"name": "Updated Wallet Name"}'

For further customization, refer to the API Reference. Using Curl provides flexibility for testing and managing Signchain operations directly from the command line.