Sign Transaction
Sign a created transaction
As seen earlier, the transaction process has been split in 3 steps. Once a transaction has been created, it must be signed. The signature is a unique identifier created by hashing the input parameters provided while creating the transaction and wallet information of the signer. This is useful for verification purposes and prevention of forgery.
The signTransaction
function creates a signature for a transaction.
Basic Syntax
The function is called as follows:
Input Parameters
The following params are available for this function and they must be passed in as an object:
key: JWKInterface
(optional): The private key for the wallet signing the transaction. When using in web apps, this field can be left empty or theuse_wallet
string can be passed in to trigger a web wallet. The wallet key file can be loaded as follows:
environment: 'local' | 'mainnet'
(optional) : The environment on which the transaction was created.
An arlocal
instance must be running on port 1984
for the function to work with the local environment. To create one, simply run npx arlocal
in the command line. Learn more about arlocal
here.
createdTransaction: object
: The transaction object created in the earlier step.postTransaction: boolean
(optional): This boolean enables the posting of the transaction to Arweave using thesignTransaction
function itself.
Returned Data
The function call returns the following data depending on input parameters:
A signed object of type Transaction is returned by Arweave.
The
signature
key will be populated with a base64URL encoded signature hash with the help of the RSA algorithm.The
id
of a transaction is only received after posting the transaction on Arweave.On selecting the
postTransaction
option the function returns a status object along with the transaction object.status: 200
andstatusText: 'OK'
indicates a successful post request on Arweave.The transaction is signed on the selected
environment
(local
ormainnet
).
Last updated