
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
popup-js-sdk
Advanced tools
js sdk for popup DApp market.
popup-js-sdk provided to developers who need to develop DApps in the popup DApp market. It provides an interface method for querying accounts and executing smart contract methods.
npm install popup-js-sdk
import Popup from 'popup-js-sdk'
...
let popup = new Popup();
popup.setProvider(new popup.providers.HttpProvider('http://127.0.0.1:2345'));
- popup.local.* is for calling popup local methods. eg: popup.local.accountList is get all account list.
 - popup.sero.* is for calling gero node rpc when execute smart contract. eg: popup.sero.call().
 
If you need to call gero other rpc interfaces directly, you can use sero-web3
npm install sero-web3
PKis the address of the account, can be used as a tag for the account, not as a transfer from address.MainPKrcan be used as a common address,callandexecutesmart contract.MainOldPKrhas Deprecated.Balanceis a map. key = currency ,value = Minimum unit amount.PkrBase58is Dynamic collection address. Refresh every time a transaction occurs.
let accounts = popup.local.accountList();
Result:
[{
	"PK": "kvaztfuz3ZS6sNcksQYZpdGC1rUwcuv1aPkuzkLdgeNSvq5FQiURuBsqghLCY3MkxZLNm7WQ9yV2ib2UWoRpJys",
	"MainPKr": "fHBQfR5t9j3D4CsKQG78sQ3Qzdz9SS6m3XsgvgkNcpKjD1TMBEVmcJ4vhDUpkZrvPtE47DnzxRjz4Gk7xMaGZfxstnMeBjZF1dWeQaC3dxLrPPa4wQoGdXeJuihdTKwxf5K",
	"MainOldPKr": "2QwcGasRUYwF3BdTDFh2gLAMYdayBRLqVhiKrBi7apqB1ftZmaUtLYN8AdTY87K3mGW2EZgh1tVCizzdy1HWM8fGBP9ZErPKawPUPexaVXqZqSa1uPbNXb5c755H1kCUn7c3",
	"Balance": {
		"SERO": 88999438296000000000
	},
	"UtxoNums": {
		"SERO": 2
	},
	"PkrBase58": "TXSgCTk7vVRDkVxmiPiWBakQtcrf5FJKcyRvGmfHh1SXBUnzopi6fqohd8K4ZCyEmvkVwzdZC2AdotcZh2B3XcnXZHRkUxrZQ76u1tzf1CURjtbchDbs4ZNRjTB86nvBGWK"
}, {
	"PK": "4xxrya2a8g6QLQuQBtdpyF49axHTnkUeDjomfk5zqG7eDZubPPubHMVkPqggZ9iE8Zy6WQVD7riRcX8TSfihs3nq",
	"MainPKr": "22ogQ9vrpiPxBgTep59koxnNzRmHAY2zi94EKp3VAhjo4r7bzETxbgqTfgUqHuuFAe5on4iagFAhXVfaooLH5JMLEhKSmzucPvHftgefGVTzAfDJLs53Pw7YnP2rcSSStxoT",
	"MainOldPKr": "Wubp9ZYJPdxLyyesrth4j3AsZVouNgt5NNgCBHiwqhUpN1ZhbmTLRWViUwxzvhpezKDgXi5ck7iXm3bjwLAHfRnSTC8FMhRTqPLvUs6vbXKXQ9VMpDefHLR4PDDLVotkbd9",
	"Balance": {},
	"UtxoNums": {},
	"PkrBase58": "22ogQ9vrpiPxBgTep59koxnNzRmHAY2zi94EKp3VAhjo4r7bzETxbgqTfgUqHuuFAe5on4iagFAhXVfaooLH5JMLEhKSmzucPvHftgefGVTzAfDJLs53Pw7YnP2rcSSStxoT"
}]
let account = popup.local.accountDetail(`pk`);
Result:
{
	"PK": "kvaztfuz3ZS6sNcksQYZpdGC1rUwcuv1aPkuzkLdgeNSvq5FQiURuBsqghLCY3MkxZLNm7WQ9yV2ib2UWoRpJys",
	"MainPKr": "fHBQfR5t9j3D4CsKQG78sQ3Qzdz9SS6m3XsgvgkNcpKjD1TMBEVmcJ4vhDUpkZrvPtE47DnzxRjz4Gk7xMaGZfxstnMeBjZF1dWeQaC3dxLrPPa4wQoGdXeJuihdTKwxf5K",
	"MainOldPKr": "2QwcGasRUYwF3BdTDFh2gLAMYdayBRLqVhiKrBi7apqB1ftZmaUtLYN8AdTY87K3mGW2EZgh1tVCizzdy1HWM8fGBP9ZErPKawPUPexaVXqZqSa1uPbNXb5c755H1kCUn7c3",
	"Balance": {
		"SERO": 88999438296000000000
	},
	"UtxoNums": {
		"SERO": 2
	},
	"PkrBase58": "TXSgCTk7vVRDkVxmiPiWBakQtcrf5FJKcyRvGmfHh1SXBUnzopi6fqohd8K4ZCyEmvkVwzdZC2AdotcZh2B3XcnXZHRkUxrZQ76u1tzf1CURjtbchDbs4ZNRjTB86nvBGWK",
}
Here need install serojs to pack and unpack data.
npm install serojs
// you can use remix solidity complie to web3deploy to get abi. and deploy with gero to get contract address.
let contractAddress = "54ZJqe8orGqAucdFqcZRupMa1WFeL6e5raCUw7FcBit9G9GZ5JFHXhNEKkhBPWRDEf1kDRLbX3qiPqSJ5H5Kasit";
let contract = serojs.callContract(abi, contractAddress);
// execute contract methods
execute(method, args) {
        let that = this;
        try{
            let packData = contract.packData(method, args);
            let executeData = {
                from: that.state.fromPKr,
                to: contractAddress,
                value: "0x0",//SERO
                data: packData,
                gas_price: "0x"+new BigNumber("1000000000").toString(16),
            };
            executeData["gas"] = popup.sero.estimateGas(executeData);
            let res = popup.local.executeContract(executeData);
            return res;
        }catch (e) {
            alert(e.message);
        }
    }
// call contract methods
call(method, args) {
    let that = this;
    try{
        let packData = contract.packData(method, args);
        let callParams = {
            from: that.state.fromPKr,
            to: contractAddress,
            data: packData
        }
        console.log(callParams);
        let callData = popup.sero.call(callParams, "latest");
        if (callData !== "0x") {
            let res = contract.unPackData(method, callData);
            return res;
        }
        return "";
    }catch (e) {
        alert(e.message);
    }
}
Please refer to the example directory
FAQs
popup js sdk for dapp developer
We found that popup-js-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.