@stove-labs/wxtz-sdk
v0.9.0-beta.0
Published
SDK for the wrapped XTZ project
Downloads
1
Readme
Wrapped-XTZ SDK
This SDK for TypeScript and JavaScript enables you to interact with Tezos smart contracts of the Wrapped-XTZ project by StakerDAO.
🚧 This software is still under development and not released. 🚧
git clone https://github.com/stove-labs/wrapped-xtz-sdk folder-name
cd folder-name
npm install
npm run build
Quickstart 🪄
Import
TypeScript
import { WXTZSDK, NetworkType } from 'wxtz-sdk';
import { InMemorySigner } from '@taquito/signer';
import { TezosToolkit } from '@taquito/taquito';
const Tezos = new TezosToolkit('tezos rpc url');
Tezos.setProvider({
signer: new InMemorySigner('signer secret key'),
});
const wXTZConfig = {
tezos: Tezos,
network: NetworkType.delphinet,
indexerUrl: 'https://you.better-call.dev',
};
JavaScript
const { WXTZSDK, NetworkType } = require('wxtz-sdk');
const { InMemorySigner } = require('@taquito/signer');
const { TezosToolkit } = require('@taquito/taquito');
const Tezos = new TezosToolkit('tezos rpc url');
Tezos.setProvider({
signer: new InMemorySigner('signer secret key'),
});
const wXTZConfig = {
tezos: Tezos,
network: NetworkType.delphinet,
indexerUrl: 'https://you.better-call.dev',
};
Usage 🕹
Typescript
(async function () {
// initialize SDK
const wXTZ = await WXTZSDK.at('KT1coreAddress', wXTZConfig);
// perform optional check
const isValidContractCode = await wXTZ.checkContractCodeIntegrity();
const createOvenContractMethod = await wXTZ.createOven('tz1aSkwEot3L2kmUvcoxzjMomb9mvBNuzFK6');
const transactionOperation = await createOvenContractMethod.send();
await transactionOperation.confirmation(1);
// interact with oven
const wXTZOven = await wXTZ.oven('KT1ovenAddress');
await wXTZOven.initialize();
// perform optional check
const isValid = await wXTZOven.checkContractCodeIntegrity();
// deposit
const depositTxOperation = await (await wXTZOven.deposit()).send({
amount: 100,
mutez: true,
});
await depositTxOperation.confirmation(1);
// withdraw
const withdrawTxOperation = await (await wXTZOven.withdraw(100)).send();
await withdrawTxOperation.confirmation(1);
// set delegate
const setDelegateTxOperation = await (await wXTZOven.setDelegate('tz1...')).send();
await setDelegateTxOperation.confirmation(1);
// remove delegate
const removeDelegateTxOperation = await (await wXTZOven.setDelegate(null)).send();
await removeDelegateTxOperation.confirmation(1);
// get delegate
const delegate = await wXTZOven.getDelegate();
// get core address
const coreAddress = await wXTZOven.getCoreAddress();
// get oven details for date/time of origination and last action, block height of origination
const ovenDetails = await wXTZOven.getDetails();
})();
API Reference
Checkout the complete TypeDoc API reference.
Tests 🧪
For running tests it is necessary to spin up a local Tezos sandbox node, migrating the test state and then executing the test runner. Make sure to have Docker running, node.js v12.x and jq installed.
npm run sandbox:start
npm run test:migrate
npm run test
License 📃
Wrapped-XTZ SDK is available under the MIT License.