Using Terminal

Overview:

Terminal is a developer's best friend, for anyone who is building DApps, artifacts or infrastructure solutions to the Ethereum space. By creating a user-friendly UI, Terminal equips their users with everything they need to know by creating logs that range from arbitrary RPC endpoints to different networks all in one spot. To learn more about Terminal and their toolkit, click here .

Requirements:

Before we begin you will need to have the following prerequisites

Setup:

In your project run the following NPM commands to download and install the dependencies into your project:

$  npm install --save @pokt-network/web3-provider #required
$  npm install --save web3 # if you don’t already have web3
$  npm install --save @terminal-packages/sdk #required

Create Pocket Provider:

To setup pocket as a provider, copy the code below:

const PocketProvider = require("pocket-js-web3-provider");
const Web3 = require("web3");

const sdk = require('@terminal-packages/sdk');

var pocketProvider = new PocketProvider("ETH", "4", "DEV123", {
  // This is just a stub, only gets called when eth_sendRawTransaction or eth_sendTransaction are called.
  transactionSigner: {
    hasAddress: async function(address) {
      return false;
    },
    signTransaction: async function(txParams) {
      console.log(txParams);
      return "0x";
    }
  },
  maxNodes: 3,
  requestTimeOut: 20000,
  sslOnly: false
});

Wrap the Pocket Provider into Terminal:

To start uploading your logs into Terminal, you first need to fetch your account's API Key and get your ProjectID from your Terminal's project settings. Next, copy the following code to wrap the provider.

const web3 = new Web3(
  new sdk.TerminalHttpProvider({
    apiKey: "abcd==",
    projectId: "abcd",
    // source can be any static or dynamic string as well
    source: sdk.SourceType.Pocket, 
    customHttpProvider: pocketProvider,// set the provider here
    web3Version: sdk.Web3Versions.one // specifiy what version of web3 you are using
  })
);

Retrieve Balance:

Lets test our code and retrieve a balance

// address we are getting the balance from
var recievingAddress = "0x74a01e5B6dAf56409476e03D6Ed7d79310fFB560";

console.log("the balance is", web3.eth.getBalance(recievingAddress).then(console.log))

Go into your project dashboard on the Terminal page, and click Logs to start seeing your logs!

Terminal Logs

Terminal Logs

Updated about a month ago



Using Terminal


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.