This is the official Ontology TypeScript SDK - a comprehensive library for developing with the Ontology blockchain in both TypeScript and JavaScript. It currently supports management of wallets, digital identities and digital assets - as well as the deployment and invocation of smart contracts.
- 进入 中文版.
- Enter English Version.
npm install 'ontology-ts-sdk' --save
or
yarn add 'ontology-ts-sdk'
git clone 'https://github.com/ontio/ontology-ts-sdk.git'
Then install the dependencies with:
yarn
Compile the project with the:
yarn build:dev // or yarn build:prod
This will create a compiled version of the SDK in the lib
directory.
The tests can be found in the test
directory. They are distinguished into three categories stored in separate subfolders:
unit
: unit tests that can be run without external or network dependenciesintegration
: integration tests that require access to one or more Blockchain nodes and test the actual interaction with the Blockchainexample
: pure sample code without test assertations that can be used for explorative testing or documentation purposes
To run the tests, use one of:
# unit tests
npm run test:unit
# integration tests
npm run test:integration
# examples
npm run test:example
# all
npm run test
or
yarn run test:unit
# integration tests
yarn run test:integration
# examples
yarn run test:example
# all
yarn test
The integration tests use several accounts on the testnet that require funding of ONG tokens in order to pay for the transactions. If there are any test failures with error messages like "insufficient funds" or similar, make sure the following accounts are properly funded:
- APT4wZG9sFQfjhyfGALPXQj5UyrQ3ZCVkY
- ANH5bHrrt111XwNEnuPZj6u95Dd6u7G4D6
- AXK2KtCfcJnSMyRzSwTuwTKgNrtx5aXfFX
- AVXf5w8WD2y6jV1Lzi36oSKYNif1C7Surc
- AdLUBSSHUuFaak9j169hiamXUmPuCTnaRz
- AJkkLbouowk6teTaxz1F2DYKfJh24PVk3r
- ATk57i8rMXFSBpHAdX3UQ4TNe48BBrfCoc
- AU9TioM24rXk5E3tUGrv8jwgBA1aZVVKDW
- AHTdWzj4jYBzbU48YBCfovvouTMc45M6iP
- AJym8dF7wZLjtoiY8C3mmYt8f2tZDxq5iz
Using import
to include the modules from 'ontology-ts-sdk'
:
import {Wallet} from 'ontology-ts-sdk';
var wallet = Wallet.create('test');
Using require
to include the modules from 'ontology-ts-sdk'
:
var Ont = require('ontology-ts-sdk');
var wallet = Ont.Wallet.create('test');
To use in the browser you must use the compiled version (as listed above).
The browser.js
file is located in the lib
directory.
Include it into the project with a <script>
tag:
<script src="./lib/browser.js"></script>
Everything will be available under the Ont
variable, just like in the require
example above.
var wallet = Ont.Wallet.create('test');
Contributors are welcome to the ontology-ts-sdk
. Before beginning, please take a look at our contributing guidelines. You can open an issue by clicking here.
If you have any issues getting setup, open an issue or reach out in the Ontology Discord.
The Ontology TypeScript SDK is availabl under the LGPL-3.0 License.