ergo-js
ergo-js copied to clipboard
JS library for Ergo integration
Ergo-js
Installing
import in body
<script src='path_to/dist/ergo.js'></script>
With npm:
npm install @ergoplatform/ergo-js
Or yarn:
yarn add @ergoplatform/ergo-js
Usage
In body:
<script src='path_to/ergo.js'></script>
<script>
ergo.sendTransaction(...)
</script>
In Node.js:
const ergo = require('@ergoplatform/ergo-js');
ergo.sendTransaction(...)
Import syntax:
import * as ergo from '@ergoplatform/ergo-js'
ergo.sendTransaction(...)
// or destructuring assignment
import { sendTransaction } from '@ergoplatform/ergo-js'
sendTransaction(...)
Documentation
Default send transaction
import { sendTransaction } from '@ergoplatform/ergo-js'
* @param {String} recipient
* @param {Number} amount
* @param {Number} fee
* @param {Array[Object({ id: number, amount: number, sk(hex): string })]}} boxesToSpend
* @param {String} chargeAddress
* @param {Number} height
* @param {Boolean} testNet = false
sendTransaction(recipient, amount, fee, boxesToSpend, chargeAddress, height, testNet)
Send transaction only with sk
import { sendWithoutBoxId } from '@ergoplatform/ergo-js'
* @param {String} recipient
* @param {Number} amount
* @param {Number} fee
* @param {String || Array[String]} sk
* @param {Boolean} testNet = false
sendWithoutBoxId(recipient, amount, fee, sk, testNet)
Form transaction and returns it
import { formTransaction } from '@ergoplatform/ergo-js'
* @param {String} recipient
* @param {Number} amount
* @param {Number} fee
* @param {Array[Object({ id: number, amount: number, sk(hex): string })]} boxesToSpend
* @param {String} chargeAddress
* @param {Number} height
formTransaction(recipient, amount, fee, boxesToSpend, chargeAddress, height)
Generate charge address from public key
import { addressFromPK } from '@ergoplatform/ergo-js'
* @param {string} pk
* @param {boolean} testNet
addressFromPK(pk, testNet)
Generate charge address from private key
import { addressFromSK } from '@ergoplatform/ergo-js'
* @param {string} sk
* @param {boolean} testNet
addressFromSK(pk, testNet)