Skip to main content

Payment with Teal Transaction

Create and send a payment with teal transaction to be signed by the user already engaged.

Preconditions#

  • User is already engaged and shared some account.

  • Transaction sender should match with one of address shared by the user, otherwise user will be alert.

Interactive Example#

Invalid Address
In order to run this example, you need to execute connect() method.
import algosdk from "algosdk";
import MyAlgoConnect from '@randlabs/myalgo-connect';
 
const algodClient = new algosdk.Algodv2("",'https://node.testnet.algoexplorerapi.io', '');
const params = await algodClient.getTransactionParams().do();

const txn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
    suggestedParams: {
        ...params,
    },
    from: sender,
    to: receiver, 
    amount: amount,
    note: note
});

const myAlgoConnect = new MyAlgoConnect();

const lsig = algosdk.makeLogicSig(new Uint8Array(Buffer.from(compiledTeal, "base64")));
lsig.sig = await myAlgoConnect.signLogicSig(lsig.logic, sender);

const signedTxn = algosdk.signLogicSigTransaction(txn, lsig);
txn Amount
int 0
>=
txn Fee
int 1000
==
&&
txn Type
byte "pay"
==
txn TxID
byte b32 $REPLACE_FOR_TXID
==
&&
&&