chain.js

A JavaScript API for web3 Transaction and Authenticating

  • Lite Version All the features that chain.js has but it is compressed as fuck
  • Standard Version The normal Version, with only simple compression

Contents

Overview

Compatible wallets (latest Version)

  • Phantom
  • (Soon get Matamask Wallet added!)

Use cases

First of all, require the library using CommonJS syntax.
For the import use require

const chain = require("chain.js"); // CommonJS

chainJS Documentation

Written by OctoDino for Statch

Get Started

Cloning the Project from GitHub

Git:

$ git clone https://github.com/statch/chainjs

GitHub CLI:

$ gh repo clone statch/chainjs

Initialize chain.js

chain.init([debugMode?])  //Load this first for the chain.js API
  • debugMode? is a Boolean where you can set if chainJS can use console.log! (Still in development)

Make a Transaction

How to make a Transaction between two Wallets? Here you have the chainJS Solution for it!

What do we use?

#chain.transaction([order])
  • order is a const we write it like in the following example!

Code example

// Simple ETH payment
const chain = require('chainjs')
    
const transaction  = {
  currency:  'sol', //The Currency to use (at the time only solona aviable!)
  amount:  1.1234133, //Transaction amount in SOL
  test:  false, //Test switch the clusterApiUrl to 'devnet'
  wallet:  'enter wallet here', //Ge the transaction
  clusterApiUrl: '' //Leave blank for devnet   
} 
      
chain.transaction(transaction)

In our const transaction = {...} we can define whith what currency our transaction is, and many more things. Let’s take a look

  • With the String Parameter currency we can declare the currency we want to use. But at the time we only Support sol!
  • In the amount Float Parameter we can add the amount of the currency that will be transferred. Here we write only the amount in SOL
  • The test Boolean Parameter toogle the Test Mode and switch the clusterApiUrl when true to devnet
  • The wallet String Parameter is to declerate the Wallet of the reciver of the transaction
  • With the String Parameter clusterApiUrl you can retrieves the RPC API URL for the specified cluster. Leave blank to set to devnet

Support

How you can Support the project?
Support Statch by writing to us on our Discord Server or committing to this Repository!
Thanks ?

Credits

Contributors

Suporters

No one :,)
…maybe you’ll be the first Supporter

GitHub

View Github