Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TransactionManager

The TransactionManager class is used to create, sign, and send NEAR transactions with a given TransactionCreator, TransactionSigner, and TransactionSender.

A new TransactionManager can be created from a NEAR Account, NEAR WalletConnection, or using the constructor.

example
const transactionManager = TransactionManager.fromAccount(account);
example
const transactionManager = TransactionManager.fromWallet(wallet);
example
const keyStore = new keyStores.UnencryptedFileSystemKeyStore(credentialsPath);
const transactionManager = new TransactionManager({
 transactionCreator: new KeyStoreTransactionCreator({
   keyStore,
   signerId: wallet.getAccountId(),
   networkId: "testnet",
   nodeUrl: "https://rpc.testnet.near.org",
 }),
 transactionSigner: new KeyStoreTransactionSigner({
   keyStore,
   signerId: wallet.getAccountId(),
   networkId: "testnet",
 }),
 transactionSender: new ProviderTransactionSender({
   provider: new JsonRpcProvider("https://rpc.testnet.near.org"),
 }),
});

Hierarchy

  • TransactionManager

Index

Constructors

constructor

Properties

Private transactionCreator

transactionCreator: TransactionCreator

Private transactionSender

transactionSender: TransactionSender

Private transactionSigner

transactionSigner: TransactionSigner

Methods

bundleCreateSignAndSendTransactions

  • Creates, signs, and sends many transactions using a TransactionSender.

    example
    const outcomes = await transactionManager.bundleCreateSignAndSendTransactions([
      {
        receiverId: "example.testnet",
        actions: [functionCall("method1", {}, DEFAULT_FUNCTION_CALL_GAS, [])],
      },
      {
        receiverId: "example.testnet",
        actions: [functionCall("method2", {}, DEFAULT_FUNCTION_CALL_GAS, [])],
      },
      {
        receiverId: "example.testnet",
        actions: [functionCall("method3", {}, DEFAULT_FUNCTION_CALL_GAS, [])],
      },
      {
        receiverId: "example.testnet",
        actions: [functionCall("method4", {}, DEFAULT_FUNCTION_CALL_GAS, [])],
      },
    ]);
    

    Parameters

    Returns Promise<FinalExecutionOutcome[]>

createSignAndSendTransaction

  • Creates, signs, and sends a transaction with a TransactionSender.

    example
    const outcome = await transactionManager.createSignAndSendTransaction({
      receiverId: "example.testnet",
      actions: [functionCall("method", {}, DEFAULT_FUNCTION_CALL_GAS, [])],
    });
    

    Parameters

    Returns Promise<FinalExecutionOutcome>

createSignedTransaction

  • Creates a new transaction with a TransactionCreator and signs it with a TransactionSigner.

    example
    const signedTransaction = await transactionManager.createSignedTransaction({
      receiverId: "example.testnet",
      actions: [functionCall("method", {}, DEFAULT_FUNCTION_CALL_GAS, [])],
    });
    

    Parameters

    Returns Promise<SignedTransaction>

createTransaction

  • Creates a new transaction given a receiverId and actions with a TransactionCreator.

    example
    const transaction = await transactionManager.createTransaction({
      receiverId: "example.testnet",
      actions: [functionCall("method", {}, DEFAULT_FUNCTION_CALL_GAS, [])],
    });
    

    Parameters

    Returns Promise<Transaction>

sendSignedTransaction

  • sendSignedTransaction(signedTransaction: SignedTransaction): Promise<FinalExecutionOutcome>
  • Send a signed transaction using a TransactionSender.

    Parameters

    • signedTransaction: SignedTransaction

    Returns Promise<FinalExecutionOutcome>

sendTransaction

  • sendTransaction(transaction: Transaction): Promise<FinalExecutionOutcome>
  • Sign and send a transaction using a TransactionSender.

    Parameters

    • transaction: Transaction

    Returns Promise<FinalExecutionOutcome>

signTransaction

  • signTransaction(transaction: Transaction): Promise<SignedTransaction>
  • Signs a transaction with a TransactionSigner.

    example
    const signedTransaction = await transactionManager.signTransaction(transaction);
    

    Parameters

    • transaction: Transaction

    Returns Promise<SignedTransaction>

Static fromAccount

  • Creates a new instance of TransactionManager with a NEAR Account.

    Parameters

    • account: Account

    Returns TransactionManager

Static fromWallet

  • Creates a new instance of TransactionManager with a NEAR WalletConnection.

    Parameters

    • wallet: WalletConnection

    Returns TransactionManager

Generated using TypeDoc