Remove dependency on AlgodClient to create a transaction

As shown [here](, we need to construct an AlgodClient just to create a transaction, which is a useless and annoying dependency.

I explain : I have a UI in Javascript which is talking to a Python backend.
I create and sign the transaction on UI side and send the signed transaction to the backend (in base64) which sends the transaction to the network.
Only my Python backend is reponsible for sending the signed transaction to the network and thus only the backend should need a AlgodClient object.
The issue is that with the current SDK API I also need a AlgodClient on UI side just to get the suggested parameters which is a useless dependency.

So for now I use something like that on UI (JS) side :

async function createTransaction(from, to, amount) {
    const algodClient = new algosdk.Algodv2('', '', '');
    const params = await algodClient.getTransactionParams().do();
    const tx = algosdk.makePaymentTxnWithSuggestedParams(from, to, amount, undefined, undefined, params);
    return tx;

This could be made a lot simpler by only needing the algosdk to create the transaction (including getting the suggested parameters).
We could even update makePaymentTxnWithSuggestedParams so that it uses the suggested parameters by default.
With a new simplified API my code would look like this :

async function createTransaction(from, to, amount) {
    const tx = algosdk.makePaymentTxnWithSuggestedParams(from, to, amount);
    return tx;

To create a transaction, the SDK needs to know the current round. See Structure - Algorand Developer Portal

The current round is included in “suggested params”.
That is why suggested params is a required argument of makePaymentTxnWithSuggestedParams.

Now, if you do not want your JS client to directly contact a algod node, you can have your backend make the suggested params query itself and have you client call your backend.
You can even cache suggested params in the backend for some period of time to reduce the number of queries to the algod node.
Caching it for 1-5s should not be an issue at all (you can even cache it for longer).

1 Like