Algorand Wallet Post Transactions API | Algorand Developer Portal

Algorand Wallet Post Transactions API

Abstract

A function, postTxns, which accepts an array of SignedTransactions, and posts them to the network.

Specification

The key words “ MUST”, “ MUST NOT”, “ REQUIRED”, “ SHALL”, “ SHALL NOT”, “ SHOULD”, “ SHOULD NOT”, “ RECOMMENDED”, “ MAY”, and “ OPTIONAL” in this document are to be interpreted as described in RFC-2119.

Comments like this are non-normative.

This ARC uses interchangeably the terms “throw an error” and “reject a promise with an error”.

Interface PostTxnsFunction

export type TxnID = string;

export type SignedTxnStr = string;

export type PostTxnsFunction = (

stxns: SignedTxnStr[],

) => Promise<PostTxnsResult>;

export interface PostTxnsResult {

txnIDs: TxnID[];

}

export interface PostTxnsError extends Error {

code: number;

data?: any;

successTxnIDs: (TxnID | null)[];

}

A PostTxnsFunction with input argument stxns:string[] and promised return value ret:PostTxnsResult:

The use of txID instead of txnID is to follow the standard name for the transaction ID.

String specification: SignedTxnStr

Defined as in ARC-0001:

[SignedTxnStr is] the base64 encoding of the canonical msgpack encoding of the SignedTxn corresponding object, as defined in the Algorand specs.

String specification: TxnID

A TxnID is a 52-character base32 string (without padding) corresponding to a 32-byte string. For example: H2KKVITXKWL2VBZBWNHSYNU3DBLYBXQAVPFPXBCJ6ZZDVXQPSRTQ.

Error standard

PostTxnsError follows the same rules as SignTxnsError from ARC-0001 and uses the same status codes as well as the following status codes:

Status Code Name Description
4400 Failure Sending Some Transactions Some transactions were not sent properly.

Semantic requirements

Regarding a call to postTxns(stxns) with promised return value ret:

An early draft of this ARC required that the size of a group of transactions must be greater than 1 but, since the Algorand protocol supports groups of size 1, this requirement had been changed so dApps don’t have to have special cases for single transactions and can always send a group to the wallet.

A dApp can always post transactions itself without the help of postTxns when a public network is used. However, when a private network is used, a dApp may need postTxns, and in this case, asking the user’s approval can make sense. Another such use case is when the user uses a specific trusted node that has some legal restrictions.

TODO: Decide whether to add an optional flag to not wait for that.

Security considerations

In case the wallet uses an API service that is secret or provided by the user, the wallet MUST ensure that the URL of the service and the potential tokens/headers are not leaked to the dApp.

Leakage may happen by accidentally including too much information in responses or errors returned by the various methods. For example, if the Node.JS superagent library is used without filtering errors and responses, errors and responses may include the request object, which includes the potentially secret API service URL / secret token headers.

Rationale

This API allows DApps to use a user’s preferred connection in order to submit transactions to the network.

The user may wish to use a specific trusted node, or a particular paid service with their own secret token. This API protects the user’s secrets by not exposing connection details to the DApp.

Security Considerations

None.

Copyright

Copyright and related rights waived via CCO.