Sign
The Sign endpoint allows you to create a digital signature for a transaction payload. This signature is generated using keys stored securely in the Signchain Vault, ensuring the transaction's integrity and security.
Endpoint
POST
/api/v1/vaults/:vaultId/sign
Test Endpoint
Request Headers
Authorization
: Bearer token for authentication. Should beBearer <Your-API-Key>
.X-Vault-Auth-Signature
: Required only whenVAULT_AUTH_SECRET_KEY
has been configured on a self-hosted vault, for securing the request with a unique signature, generated with the shared secret. Inclusion of this parameter guarantees security of your vault's private key data, by disallowing requests unless the signature is valid and matches the shared key between your backend and your self-hosted vault instance. If you're using the Signchain Hosted Vault, this parameter must not be included, otherwise the signing request will fail.Content-Type
: Must beapplication/json
.Accept
: Must beapplication/json
.
Request Parameters
vaultId
: The unique identifier of your Signchain Vault.
Request Body
The request body must include the transaction data to be signed:
{
"chain": "<Your-Contracts-Chain>",
"contract": "<Your-Contract-Address>",
"sender": "<Your-Users-Address>",
"uniq": "<Your-Optional-Contracts-Uniq-Value>",
"signer": "<Your-Optional-Contracts-Signer-Value>",
"abi": {
...Your_Contract_Function_ABI_Item
},
"args": [
...Your_Contract_Function_Arguments
]
}
Required Field
chain
: The chain which the contract exists on, should be one of the supported chainsethereum
,sepolia
,bsc
,bsc-testnet
,polygon
,amoy
,avalanche
,fuji
. If you are developing locally, uselocal
and ensure you submit theISignable
contract'suniq
andsigner
values.contract
: The deployed contract address from where Signchain can lookupuniq
andsigner
values.sender
: The user's wallet address from where the transaction will be sent from.uniq
: (Optional) Thebytes32
uniq
value from the deployed contract. This is required forlocal
development, or for chains which are not supported, and where Signchain can't lookup the value automatically.signer
: (Optional) Theaddress
signer
value from the deployed contract. This is required forlocal
development, or for chains which are not supported, and where Signchain can't lookup the value automatically.abi
: The ABI Item description for the method you are signing for. An ABI is an array of ABI Items, make sure you filter the ABI to just select the ABI Item related to your contact method. The client libraries do this selection automatically based on thefunctionName
argument tosign
.args
: The contract function's arguments as an array, excluding the lastsignature
parameter.
Response
On success, the API returns the transaction signature:
{
"success": Request_Success_Status,
"data": {
"submissionHash": "<Your-Sign-Request-Submission-Hash>",
"args": [
...Your_Supplied_Arguments,
{
...Nonce_R_S_V_Signature_Struct
}
]
},
"error": "<Request-Error-Message>"
}
Response Fields
success
: A booleantrue
orfalse
determining whether thesign
request was successful or not. If thesign
request was not successful, this value will befalse
and theerror
field will be populated.error
: A string error message, only sent if thesuccess
parameter isfalse
.data
: The response data for the request, only sent if thesuccess
parameter istrue
.submissionHash
: The unique identifier for thissign
response, allowing you to correlate the transaction data on Signchain's Dashboard with a blockchain specific transaction hash, after the transaction has been submitted by the user. Supply this value to thesubmit
endpoint once the transaction has been executed.args
: A full list of arguments which you supplied in the request that can be sent on-chain, with the signature argument appended to the list. These arguments should be provided back to the user in their entirety in order to execute the transaction.
Example Request
Here's an example of how to sign a transaction using curl
:
curl -X POST https://signchain.net/api/v1/vaults/:vaultId/sign \
-H "Authorization: Bearer <Your-API-Key>" \
-H "Content-Type: application/json" \
--data-binary @- <<EOF
{
"chain": "<Your-Contracts-Chain>",
"contract": "<Your-Contract-Address>",
"sender": "<Your-Users-Address>",
"abi": $(cat MyContractABI.json | jq '.[] | select(.name == "<Your-Function-Name>")'),
"args": [...<Your-Function-Arguments>]
}
EOF
Error Handling
This endpoint can return the following errors:
- 400 Bad Request: Missing or invalid transaction data.
- 401 Unauthorized: Incorrect API key or
X-Vault-Auth-Signature
. - 404 Not Found: The specified vault or wallet address does not exist.
- 500 Internal Server Error: An unexpected error occurred while processing the request.
Refer to the Authentication documentation to ensure proper setup of your API keys and request signatures.
This endpoint is critical for secure transaction processing, ensuring only authorized parties can initiate cryptographic operations using your self-hosted Signchain Vault.