IDEP.js is a javascript SDK that allows browsers and node.js clients to interact with IDEP Network blockchain.
- Works both in node.js and in browser environments.
- Written in Typescript.
- Wallet creation, persistence, restoration (from the mnemonic phrase or a private key). Can be used to create wallets for other blockchains.
- Querying the idep blockchain, sending transactions.
- Safe encryption, based on the native APIs (crypto in node, subtleCrypto in a browser).
- Uses protocol buffers.
or
If you are in a hurry, start here.
- Install idep.js with either yarn or npm.
- Create client's instance.
import {createNewClient} from 'idep.js';
const client = createNewClient(); // uses default configuration
- Create new wallet. Password is used to encrypt the private key. You will need it to make a transaction. Name is used for persistence.
const wallet = await client.wallet.createNew('encryptionPwd', 'walletName');
- After creating your wallet successfully, you can start making queries and transactions! Below1 you can find a list with possible ones that you can make with the idep.js.
Disclaimer: Using await in a global scope is only supported with node versions higher than 17. If using older versions, wrap examples below in async functions.
To start, import and create the client.
import {createNewClient} from 'idep.js';
const client = createNewClient({
nodeUrl: 'http://159.89.84.111:26657',
chainId: 'SanfordNetwork',
fee: {
gas: '7000',
amount: [{ denom: 'idep', amount: '500' }],
},
}); // default config
Configuration can be omitted, in that case the default one is going to be used.
const client = createNewClient()
After wallet is created, retrieved, or restored; it's stored on the client's instance. Private key is encrypted with provided password.
const wallet = await client.wallet.createNew('encryptionPwd', 'walletName');
const {mnemonic, publicKey, address} = wallet;
This is the only time when mnemonic phrase can be accessed. Make sure to store it securely. Naming a wallet is optional (it defaults to the wallet's address).
const wallet = await client.wallet.retrieveSavedWallet('name');
const {publicKey, address} = wallet;
With a mnemonic phrase:
const mnemonic = 'power thing inmate obscure rubber frequent grit hair below museum notable reopen spoon prize family caught axis host';
const wallet = await client.wallet.restoreWithSeed(mnemonic, 'password');
With private key:
const privateKey = 'hexEncodedPrivateKeyString';
const wallet = await client.wallet.restoreWithPrivateKey(privateKey, 'password')
const address = 'idep126dfeu0d6awmdjy29e4f04eg0g3kvcpz9dazru';
const denom = 'idep'
const response = await client.bank.checkBalance(address, denom);
console.log(response); // {balance: {amount: '10000000150', denom: 'idep'}}
const txResult = await client.bank.msgSend({
recipient: 'idep126dfeu0d6awmdjy29e4f04eg0g3kvcpz9dazru',
amount: [{
denom: 'idep',
amount: '25'
}],
}, {
from: client.wallet.address, // optional
pub_key: client.wallet.publicKey, // optional
fee: {
gas: '7000',
amount: [{
denom: 'idep',
amount: '700'
}],
}, // optional
simulate: false, // optional
password: 'password', // needed to decrypt a private key, which is needed to sign the tx
});
console.log(txResult); // 'Tx hash 26919CA117C5D5240AF144D6A7765AE31372D9E167CB596A46210AC986F28C03'
You also can simulate the transaction beforehand so you get required gas estimate. To do it, simply change the simulate flag to true.
const txHash = '26919CA117C5D5240AF144D6A7765AE31372D9E167CB596A46210AC986F28C03';
const status = await client.rpc.checkTx(txHash);
- checkAccountInfo (queryAccount)
- checkAuthParams (queryParams)
- checkBalance (queryBalance)
- checkALlBalances (queryAllBalances)
- checkSupply (querySupplyOf)
- checkParams (queryParams)
- checkBalance (queryAllBalances)
- checkALlBalances (queryAllBalances)
- msgSend
- msgMultiSend
- checkSupply (querySupply)
- checkOwner (queryOwner)
- checkCollection (queryCollection)
- checkDenom (queryDenom)
- checkMultipleDenoms (queryDenoms)
- checkNft (queryNFT)
- msgIssueDenom
- msgMintNFT
- msgEditNFT
- msgTransferNFT
- msgBurnNFT
Chat with the team on the IDEP Discord server IDEP.js channel!
Something doesn't work as expected? Open a new issue!