Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<script src="nebPay.js"></script>
<script >
var NebPay = require("nebpay");
var nebPay = new NebPay();
var serialNumber; //transaction serial number
var intervalQuery; //periodically query tx results
//initiate the transaction with a button click, here is an example of calling a smart contract
function onButtonClick() {
var to = dappAddress; //the smart contract address of your Dapp
var value = "0";
var callFunction = "" //the function name to be called
var callArgs = "" //the parameter, it's format JSON string of parameter arrays, such as'["arg"]','["arg1","arg2]'
var options = {
goods: { //commodity description
name: "example"
//Send transaction (here is smart contract call)
serialNumber =, value, callFunction, callArgs, options);
//Set a periodically query
intervalQuery = setInterval(function() {
}, 10000); //it's recommended that the query frequency is between 10-15s.
//Query the result of the transaction. queryPayInfo returns a Promise object.
function funcIntervalQuery() {
nebPay.queryPayInfo(serialNumber) //search transaction result from server (result upload to server by app)
.then(function (resp) {
console.log("tx result: " + resp) //resp is a JSON string
var respObject = JSON.parse(resp)
if(respObject.code === 0){
//The transaction is successful
clearInterval(intervalQuery) //stop the periodically query
.catch(function (err) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.