How to use the algosdk.Algod function in algosdk

To help you get started, we’ve selected a few algosdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PureStake / api-examples / javascript-examples / get_versions.js View on Github external
// 
// Code borrowed and extended from https://developer.algorand.org/docs/javascript-sdk
//
// Example using PureStake token object, replacing the token as a string
//

// DEPRECATED 12/30/20 with Algod v1 API Shutdown

const algosdk = require('algosdk');
const baseServer = "https://testnet-algorand.api.purestake.io/ps1"
const port = "";
const token = {
    'X-API-Key': 'B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab'
}

const algodclient = new algosdk.Algod(token, baseServer, port);

(async () => {
    console.log(await algodclient.versions());
})().catch(e => {
    console.log(e);
});
github PureStake / api-examples / javascript-examples / submit_tx.js View on Github external
// Both algodclient objects are necessary, as the params call is application/json and the SDK does not allow by request header assignment
// The TestNet account in this example is U2VHSZL3LNGATL3IBCXFCPBTYSXYZBW2J4OGMPLTA4NA2CB4PR7AW7C77E - PureStake cannot guarantee any funds will exist to execute this example
// To add Algo's - https://bank.testnet.algorand.network

// DEPRECATED 12/30/20 with Algod v1 API Shutdown


const algosdk = require('algosdk');
const baseServer = "https://testnet-algorand.api.purestake.io/ps1"
const port = "";

const token = {
    'X-API-key' : 'B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab',
}

const algodclient = new algosdk.Algod(token, baseServer, port); 

var mnemonic = "code thrive mouse code badge example pride stereo sell viable adjust planet text close erupt embrace nature upon february weekend humble surprise shrug absorb faint"; 
var recoveredAccount = algosdk.mnemonicToSecretKey(mnemonic); 
console.log(recoveredAccount.addr);


(async() => {

    let params = await algodclient.getTransactionParams();
    let endRound = params.lastRound + parseInt(1000);

    let txn = {
        "from": recoveredAccount.addr,
        "to": "AEC4WDHXCDF4B5LBNXXRTB3IJTVJSWUZ4VJ4THPU2QGRJGTA3MIDFN3CQA",
        "fee": 10,
        "amount": 2,
github PureStake / api-examples / javascript-examples / get_tx.js View on Github external
// 
// Code borrowed and extended from https://developer.algorand.org/docs/javascript-sdk
//
// Example using PureStake token object 
//

// DEPRECATED 12/30/20 with Algod v1 API Shutdown

const algosdk = require('algosdk');
const baseServer = "https://testnet-algorand.api.purestake.io/ps1"
const port = "";
const token = {
    'X-API-Key': 'B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab'
}

const algodclient = new algosdk.Algod(token, baseServer, port);

(async () => {
    console.log(await algodclient.transactionById('3J7Z46VKGJ6VATCHOE3I2JZXVDXKAWOKO3JJCR6R7EEX5VBKEATQ'));
})().catch(e => {
    console.log(e);
});