Skip to main content

Appl Create Transaction

Create and send a create application 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 number
Invalid number
Invalid number
Invalid number
In order to run this example, you need to execute connect() method.
The following codes allow you to create and sent to MyAlgo Connect an application transaction to be sign by the user. There are two alternatives to create it. Pick the one you prefere.
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.makeApplicationCreateTxnFromObject({
    suggestedParams: {
        ...params,
    },
    from: sender,
    numLocalByteSlices: 4,
    numGlobalByteSlices: 2,
    numLocalInts: 0,
    numGlobalInts: 2,
    approvalProgram: new Uint8Array(Buffer.from("AiADAAEFIjEYEkEAAiNDMRkkEg==", "base64")),
    clearProgram: new Uint8Array(Buffer.from("AiABASJD", "base64")),
    onComplete: 0,
});

const myAlgoConnect = new MyAlgoConnect();
const signedTxn = await myAlgoConnect.signTransaction(txn.toByte());
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 = {
    ...params,
    type: "appl",
    from: sender,
    appLocalByteSlices: 4,
    appGlobalByteSlices: 2,
    appLocalInts: 0,
    appGlobalInts: 2,
    appApprovalProgram: new Uint8Array(Buffer.from("AiADAAEFIjEYEkEAAiNDMRkkEg==", "base64")),
    appClearProgram: new Uint8Array(Buffer.from("AiABASJD", "base64")),
    appOnComplete: 0,
}

const myAlgoConnect = new MyAlgoConnect();
const signedTxn = await myAlgoConnect.signTransaction(txn);