espanicon-sdk 1.0.2
Install from the command line:
Learn more about npm packages
$ npm install @espanicon/espanicon-sdk@1.0.2
Install via package.json:
"@espanicon/espanicon-sdk": "1.0.2"
About this version
Espanicon SDK is a custom JS SDK for the ICON Network created specifically to be used in Espanicon projects related to development in the ICON Network. If you find it useful for your projects you are free to use it but we highly recommend that you use the official ICON JS SDK.
The benefit of using the Espanicon SDK is a more simpler syntax to make very common readonly queries to the ICON Network, and the methods for signed transactions returns a JSON object (ICON JSON-RPC) that can be given to any ICON wallet that implements the JS Provider standard (currently ICONex and Hana) and this will allow the signed transactions to be handled securely with the wallets without the need to expose the private keys, this is highly important when implementing an interface for users to sign transactions in a web app or platform that you might be building in the ICON Network. The downside is that you lose the wide arrange of options and customization that are possible to implement when you directly use the official ICON JS SDK.
Espanicon SDK is available via NPM as a github package, to install you just need to run the following command:
npm install git@github.com:Espanicon/espanicon-sdk.git
Depending on whether you using the Espanicon SDK on the server side (via nodejs) or on the client side (web) the way to import it will vary, is important to choose the correct method because internally the request are being handle in different ways, for nodejs the http and https modules are used and for the web the fetch API is used.
const espaniconLib = require('@espanicon/espanicon-sdk');
import espaniconLib from '@espanicon/espanicon-sdk';
The library exposes an object that divides the methods according to the smart contract they related to:
{
cps: {
getCPSPeriodStatus,
getCPSProposalKeysByStatus,
getCPSProposalDetailsByHash,
getCPSProposalVoteResultsByHash,
getAllCPSProposals
},
governance: {
getScoreApi,
getIcxBalance,
getTxResult,
getTxByHash,
getPrep,
parsePrepData,
getPreps,
getBonderList,
setBonderList,
getLastBlock
},
governance2: {
getScoreStatus,
getStepPrice,
getStepCosts,
getMaxStepLimit,
isInScoreBlackList,
getVersion,
getRevision,
getProposal,
getProposals,
approveNetworkProposal,
rejectNetworkProposal
},
lib: {
hexToDecimal,
decimalToHex,
fromHexInLoop
}
};
Params:
- No params.
Params:
- status: one of the following => "_active" | "_completed" | "_disqualified" | "_paused" | "_pending"
Params:
- hash: hash key of a CPS proposal.
Params:
- hash: hash key of a CPS proposal.
Params:
- No params.
Params:
- address: ICON SCORE address.
Params:
- address: ICON wallet address.
Params:
- txHash: ICON Network tx hash.
Params:
- txHash: ICON Network tx hash.
Params:
- prepAddress: wallet address of a prep.
Params:
- prep: the object result of a getPrep(prepAddress) query AS IS.
Params:
- height (optional): block height.
Params:
- prepAddress: wallet address of a prep.
Params:
- prepAddress: wallet address of a prep.
- arrayOfBonderAddress: an array of up to 10 addresses to be set as bonders for the given prep (prepAddress).
Params:
- No params.
Params:
- address: ICON SCORE address.
Params:
- No params.
Params:
- No params.
Params:
- contextType: 'invoke' for sendTransaction, 'query' for call.
Params:
- address: SCORE address to query.
Params:
- No params.
Params:
- No params.
Params:
- proposalId: ID of network proposal.
Params:
- No params.
Params:
- proposalId: ID of the proposal.
- prepAddress: wallet address of a prep.
Params:
- proposalId: ID of the proposal.
- prepAddress: wallet address of a prep.
- ICON Documentation: https://docs.icon.community/
- CPS Documentation on Github: https://github.com/icon-community/CPS/wiki
- Documentation for governance2 SCORE: https://github.com/icon-project/governance2
- Documentation for governance SCORE: https://github.com/icon-project/governance