Skip to content

Instantly share code, notes, and snippets.

View yupnano's full-sized avatar

yupnano yupnano

  • nebulas
  • Beijing
View GitHub Profile
//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.
<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
//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": {
<script src="nebPay.js"></script>
<script >
var NebPay = require("nebpay");
var nebPay = new NebPay();
var serialNumber; //交易序列号
var intervalQuery; //定时查询交易结果
//点击按钮发起交易, 这里为调用智能合约的例子
function onButtonClick() {
var to = dappAddress; //Dapp的合约地址