nest-tonweb
v1.0.3
Published
A Nest module wrapper for tonweb
Downloads
126
Maintainers
Readme
Installation
npm install --save nest-tonweb
Quick start
Import TonwebModule
into the root AppModule
and use the forRoot()
method to configure it. This method accepts the same options object as Tonweb.HttpProvider()
function from the tonweb package:
import { Module } from '@nestjs/common';
import { TonwebModule } from 'nest-tonweb';
@Module({
imports: [
TonwebModule.forRoot({
// options
}),
],
})
export class AppModule {}
Afterward, the tonweb instance will be available to inject across entire project (and in your feature modules, being TonwebModule a global one) using the TONWEB_MODULE_PROVIDER injection token:
import { Inject, Injectable } from '@nestjs/common';
import { TONWEB_MODULE_PROVIDER } from 'nest-tonweb';
import TonWeb from 'tonweb';
@Injectable()
export class BlockchainService {
constructor(
@Inject(TONWEB_MODULE_PROVIDER)
private readonly tonweb: TonWeb,
) {}
public createWallet(publicKey) {
const WalletClass = this.tonweb.wallet.all['v4R2'];
const wallet = new WalletClass(this.tonweb.provider, {
publicKey: publicKey,
wc: 0,
});
return wallet;
}
}
Change Log
See Changelog for more information.
Contributing
Contributions welcome! See Contributing.
Author
Ruslan Sorokin | Telegram
License
Licensed under the MIT License - see the LICENSE file for details.