You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
consttx=newTransaction([{funds: {ERG: 100000,tokens: [{tokenId: 'token id',amount: '1'}],},toAddress: 'address',additionalRegisters: {},},]);constunsignedTx=(awaittx.build()).toJSON();// using ergo walletconstsignedTx=awaitergo.sign_tx(unsignedTx);awaitergo.submit_tx(signedTx);
Multiple recipients / airdrop
consttokenId='<tokenId>'constrecipients=[{address: '<address_1>',amount: 1},{address: '<address_2>',amount: 10},{address: '<address_3>',amount: 100},{address: '<address_4>',amount: 1000}]consttx=newTransaction(recipients.map(rec=>{return{funds: {ERG: 100000,tokens: [{ tokenId,amount: rec.amount}],},toAddress: rec.address,additionalRegisters: {},}}));constunsignedTx=(awaittx.build()).toJSON();// using ergo walletconstsignedTx=awaitergo.sign_tx(unsignedTx);awaitergo.submit_tx(signedTx);
Immutability
// Methods return a new instance instead of modifying the old instanceconstINPUT_0=neweUTXOBox(tokenToRentasExplorerBox);// modify ergoTree valueconstOUTPUT_0=INPUT_0.sendTo(changeAddress);OUTPUT_0.ergoTree!==INPUT_0.ergoTree;// setRegisters - add registers and return new instanceconstINPUT_0=neweUTXOBox(tokenToRentasExplorerBox);constOUTPUT_0=INPUT_0.setRegisters({R5: {value: price,type: Long},R6: {value: period,type: Long},});consttx=newTransaction([[INPUT_0,OUTPUT_0],// setting those boxes as first input and output of the transaction - handy for smart contracts{funds: {ERG: 100000,tokens: [{tokenId: 'token id',amount: '1'}],},toAddress: 'address',additionalRegisters: {},},]);// reset registers - remove all registers and return new instanceconstOUTPUT_0=INPUT_0.resetRegisters();