Set up
The Tezos Payments JavaScript package supports Node.js 16.7.0 or later. Make sure that you have the supported version:
node --version
Install the JavaScript package​
Add the package to your project:
- NPM
- Yarn
npm install --save tezospayments
yarn add tezospayments
Set up the Tezos Payments​
Tezos Payments (TezosPayments
) is a class with which you’ll create payment links. One instance is used for one service.
Create an instance of the TezosPayments
class:
- TypeScript
- JavaScript
import { TezosPayments } from 'tezospayments';
// ...
const tezospayments = new TezosPayments({
serviceContractAddress: '<contract address of your service>',
signing: {
apiSecretKey: '<API secret key of this service>'
}
});
const { TezosPayments } = require('tezospayments');
// ...
const tezospayments = new TezosPayments({
serviceContractAddress: '<contract address of your service>',
signing: {
apiSecretKey: '<API secret key of this service>'
}
});
If you need to specify a network use the network option:
- TypeScript
- JavaScript
import { TezosPayments } from 'tezospayments';
// ...
const tezospayments = new TezosPayments({
serviceContractAddress: '<contract address of your service>',
signing: {
apiSecretKey: '<API secret key of this service>'
},
network: { name: 'hangzhounet' }
});
const { TezosPayments } = require('tezospayments');
// ...
const tezospayments = new TezosPayments({
serviceContractAddress: '<contract address of your service>',
signing: {
apiSecretKey: '<API secret key of this service>'
},
network: { name: 'hangzhounet' }
});