ArweaveKit Docs
  • ArweaveKit
    • Introduction
  • 🔐Wallets
    • Introduction to Wallets
    • Create Wallet
    • Get Wallet Address
    • Get Wallet Balance
    • Wallet Plugins
  • 💳ARWEAVE WALLET KIT
    • Introduction to Arweave Wallet Kit
    • Setup
    • Connect Button
    • Hooks
    • Customization
  • 🏦Transactions
    • Introduction to Transactions
    • Create Transaction
    • Sign Transaction
    • Post Transaction
    • Get Transaction Status
    • Get Transaction
    • Create and Post Transaction with Othent
    • Transaction Plugins
  • 📄SMART CONTRACTS
    • Introduction to Smart Contracts
    • Create Contract
    • Write Contract
    • Read Contract State
    • View Contract State
    • Write Contract with Othent
    • Read Contract with Othent
    • Smart Contract Plugins
  • ✅AUTH
    • Introduction to Auth
    • Connect
    • Disconnect
    • Get Active Address
    • Get Permissions
    • Get Wallet Names
    • Get All Addresses
    • Get Active Public Key
    • Is Installed
    • Log In with Othent
    • Log Out with Othent
    • Get User Details with Othent
    • Auth Plugins
  • 🔐Encryption
    • Introduction to Encryption
    • Encrypt Data with AES
    • Decrypt Data with AES
    • Encrypt AES Key with RSA
    • Decrypt AES Key with RSA
    • Encryption Plugins
  • 🌐GRAPHQL
    • Introduction to GraphQL
    • Query All Arweave Transactions
    • Query Arweave Data
    • Query Arweave Transactions
    • GraphQL Plugins
  • 🗺️RoadMap
    • Features
  • 📘REFERENCES
    • ArweaveKit in Browser Environments
  • 🛠️SUPPORTING TOOLS
    • Arweave StarterKit
Powered by GitBook
On this page
  • Basic Syntax
  • Input Parameters
  • Returned Data

Was this helpful?

  1. Transactions

Sign Transaction

Sign a created transaction

PreviousCreate TransactionNextPost Transaction

Last updated 3 months ago

Was this helpful?

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:

import { signTransaction } from 'arweavekit/transaction'

const signedTransaction = await signTransaction({params}) 

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 the use_wallet string can be passed in to trigger a web wallet. The wallet key file can be loaded as follows:

import { readFileSync } from 'fs';

const key = JSON.parse(readFileSync('wallet.json').toString());
  • 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 .

  • createdTransaction: object : The transaction object created in the earlier step.

  • postTransaction: boolean (optional): This boolean enables the posting of the transaction to Arweave using the signTransaction function itself.

Example
const signedTransaction = await signTransaction({
    createdTransaction: createdTransaction,
    key: { KEY_OBJECT },
    environment: 'mainnet',
});

This call signs a created transaction on mainnet on a node environment.

Returned Data

The function call returns the following data depending on input parameters:

    • 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 and statusText: 'OK' indicates a successful post request on Arweave.

    • The transaction is signed on the selected environment (local or mainnet).

A signed object of type is returned by Arweave.

🏦
here
Transaction