This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="nebPay.js"></script> | |
<script > | |
var NebPay = require("nebpay"); | |
var nebPay = new NebPay(); | |
var serialNumber; //交易序列号 | |
var intervalQuery; //定时查询交易结果 | |
//点击按钮发起交易, 这里为调用智能合约的例子 | |
function onButtonClick() { | |
var to = dappAddress; //Dapp的合约地址 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//query failed. (There is no record for this serial number, you can query several more times) | |
{ | |
"code": 1, | |
"data": {}, | |
"msg": "payId ZBTSkk74dB4tPJI9J8FDFMu270h7yaut get transaction error" | |
} | |
//query success | |
{ | |
"code": 0, | |
"data": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//for testnet, you need to specify options.callback, bescause it's mainnet by default | |
var options = { | |
callback: NebPay.config.testnetUrl //to tell app where to send tx result, and tell queryPayInfo where to query tx result. | |
} | |
//to send transaction | |
serialNumber = nebPay.pay(to, value, options) | |
//to query tx result | |
nebPay.queryPayInfo(serialNumber, options); //note that here you need to specify options argument. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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 |