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
IMA.JS is a Typescirpt/Javascript library which implements client for SKALE Interchain Messaging Agent (IMA).
Implementation Example
Package Install
npm install --save @skalenetwork/ima-js
Usage
Initialization
There are 2 ways to use IMA.js library in your project:
As a single object that contains both Mainnet and Schain (SKALE chain) parts
Use Mainnet and Schain objects separately
First approach is more convenient in general because single IMA object have simplified API for some functionality that
requires both Mainnet and Schain interactions, but in this case you will need two web3 objects to be available at the same time.
Second approach is more flexible but requires more developer work in some cases.
Working with a single IMA object
Import and init single IMA-JS object:
import{IMA}from'@skalenetwork/ima-js';importmainnetAbifrom'./mainnetAbi.json';// your local sourcesimportschainAbifrom'./schainAbi.json';// your local sourcesconstMAINNET_ENDPOINT='[YOUR_ETHEREUM_MAINNET_ENDPOINT]';constSCHAIN_ENDPOINT='[YOUR_SCHAIN_ENDPOINT]';constmainnetWeb3=newWeb3(MAINNET_ENDPOINT);constsChainWeb3=newWeb3(SCHAIN_ENDPOINT);letima=newIMA(mainnetWeb3,sChainWeb3,mainnetAbi,sChainAbi);
Accessing Mainnet and Schain parts:
Mainnet: ima.mainnet - equals to MainnetChain object
sChain: ima.schain - equals to Schain object
Working with 2 separate objects
Import and init Mainnet object:
import{MainnetChain}from'@skalenetwork/ima-js';importmainnetAbifrom'./mainnetAbi.json';// your local sourcesconstMAINNET_ENDPOINT='[YOUR_ETHEREUM_MAINNET_ENDPOINT]';constmainnetWeb3=newWeb3(MAINNET_ENDPOINT);letmainnet=newMainnetChain(mainnetWeb3,mainnetAbi);
Import and init Schain object:
import{SChain}from'@skalenetwork/ima-js';importschainAbifrom'./schainAbi.json';// your local sourcesconstSCHAIN_ENDPOINT='[YOUR_SCHAIN_ENDPOINT]';constsChainWeb3=newWeb3(SCHAIN_ENDPOINT);letschain=newSChain(sChainWeb3,schainAbi);
ETH and token transfers
Detailed documentation about ETH and token transfers using IMA-JS can be found here:
[ETH transfers] missing link
[ERC20 token transfers] missing link
[ERC721 token transfers] missing link
[ERC1155 token transfers] missing link
Signing transactions
There are 2 ways to sign a transaction in the current version of IMA-JS:
Signing directly with private key
Signing with an external provider (currently only Metamask is supported)
Signing with private key
To sing and send a transaction using local private key you should specify privateKey and address in the txOpts object:
// init ima objectconsttxOpts={address: "[ADDRESS]",privateKey: "[PRIVATE_KEY]"}this.state.sChain.withdrawETH(receiverAddress,amountWei,txOpts);
Signing with Metamask
Just drop privateKey from the txOpts object to trigger external signing, keep address field:
// init ima objectconsttxOpts={address: "[ADDRESS]"}this.state.sChain.withdrawETH(receiverAddress,amountWei,txOpts);
The text was updated successfully, but these errors were encountered:
IMA.js
IMA.JS is a Typescirpt/Javascript library which implements client for SKALE Interchain Messaging Agent (IMA).
Implementation Example
Package Install
Usage
Initialization
There are 2 ways to use IMA.js library in your project:
First approach is more convenient in general because single IMA object have simplified API for some functionality that
requires both Mainnet and Schain interactions, but in this case you will need two
web3
objects to be available at the same time.Second approach is more flexible but requires more developer work in some cases.
Working with a single IMA object
Import and init single IMA-JS object:
Accessing Mainnet and Schain parts:
ima.mainnet
- equals toMainnetChain
objectima.schain
- equals toSchain
objectWorking with 2 separate objects
Import and init Mainnet object:
Import and init Schain object:
ETH and token transfers
Detailed documentation about ETH and token transfers using IMA-JS can be found here:
missing link
missing link
missing link
missing link
Signing transactions
There are 2 ways to sign a transaction in the current version of IMA-JS:
Signing with private key
To sing and send a transaction using local private key you should specify
privateKey
andaddress
in thetxOpts
object:Signing with Metamask
Just drop
privateKey
from thetxOpts
object to trigger external signing, keepaddress
field:The text was updated successfully, but these errors were encountered: