Submit and send the signed transaction
On this page
As a Notardec API consumer You have a function to send the signed transaction, so that You don’t have to use the TEOS API directly
POST /transactions/{transactionId}/submit
{
"signerAddress": "string",
"signedTransaction": "string",
"description": "string"
}
- transactionId: The ID of the transaction we want to submit.
- signerAddress: The ID of the wallet that this transaction belongs to.
- signedTransaction: Signed transaction data
Transaction data
To confirm the transaction, you need to get the signing data
The “signedTransaction” parameter is a hashed signing data parameters. There is an example how to hash this using ethereum library in TypeScript
import type { Wallet } from 'ethers';
async function submitTransaction (
transactionId: string,
signingParameters: {
TargetAddress: string;
Nonce: string;
GasPrice: string;
GasLimit: string;
DataToSign: string;
},
transactionWallet: Wallet,
){
const _transaction = {
nonce: +signingParameters.Nonce,
value: 'Amount' in signingParameters ? +signingParameters['Amount' as any] : 0,
gasLimit: +signingParameters.GasLimit,
gasPrice: +signingParameters.GasPrice,
to: signingParameters.TargetAddress,
data: signingParameters.DataToSign,
};
const signedTransaction = await transactionWallet.sign(_transaction);
const payload = {
transactionId: transactionId
signerAddress: signingParameters.TargetAddress,
signedTransaction: signedTransaction,
description: "Submit transaction"
}
}
const response = await submitSignedTransaction(NOTARDEC_API_KEY, request.token, payload)
Code Example
async function submitSignedTransaction(
apiKey: string,
token: string,
payload: SubmitSignedTransactionPayload
): Promise<SubmitSignedTransactionDto> {
const result = await axios.post(`${process.env.NOTARDEC_URL}/transactions/${payload.transactionId}/submit`, payload, {
headers: {
'X-API-KEY': apiKey,
Authorization: `Bearer ${token}`,
},
});
return result.data;
}
Here, the first parameter we pass is the Notardec Key, the second is the token, the third is the request body. The request body and the response body will have the following form:
Request:
{
"transactionId": "string",
"signerAddress": "string",
"signedTransaction": "string",
"description": "string"
}
Response
{
"value": {
"status": "string",
"transactionId": "string"
}
}