Responding To Sign And Post Transactions Requests
Overview
If your provider is able to both sign and post transactions, this method can simply be implemented to allow clients to perform both these methods within one method.
Responding to a sign and post transactions request
Once our provider object has been initialized, we can simply listen to events and respond:
- Javascript
- TypeScript
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
// initialized provider
provider.onSignAndPostTransactions(({ params }) => {
// ... using the `params.txns` parameter, the provider signs and posts the transactions to the network and returns the transaction ids
return {
providerId,
txnIDs: [
'OKU6A2Q...',
],
};
});
import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
// initialized provider
provider.onSignAndPostTransactions(({ params }: IAVMWebProviderCallbackOptions) => {
// ... using the `params.txns` parameter, the provider signs and posts the transactions to the network and returns the transaction ids
return {
providerId,
txnIDs: [
'OKU6A2Q...',
],
};
});
caution
If this method is not supported, then a MethodNotSupportedError
should be thrown.
caution
If there is a group of atomic transactions, but the computed group ID doesn't match the assigned ID, then a InvalidGroupIdError
should be thrown.
caution
If any of the transactions are malformed, then a InvalidInputError
should be thrown.
caution
If the transactions fail to be accepted by the network, then a FailedToPostSomeTransactionsError
should be thrown.