Angular service wrapper for the NeoLine N3 dAPI. Detects the injected provider, waits for READY events, and exposes typed methods for common, read, write, and event APIs.
- Library package:
@smartargs/ngx-neoline - npm: https://www.npmjs.com/package/@smartargs/ngx-neoline
- Demo app included in this repo for local testing
- Typed APIs
- Common:
getNetworks,getAccount,getPublicKey - Read:
getProvider,getBalance,getStorage,invokeRead,invokeReadMulti,verifyMessageV2,getBlock,getTransaction,getApplicationLog,pickAddress,AddressToScriptHash,ScriptHashToAddress - Write:
send,invoke,invokeMultiple,signMessageV2,signMessageWithoutSaltV2,signTransaction,switchWalletNetwork,switchWalletAccount
- Common:
- Events:
on(event)Observable wrapper using provideraddEventListener/removeEventListener - Error guard:
isNeolineError(err)for safe narrowing of NeoLine error objects - Provided in root, no module setup required
- Angular >= 14
- RxJS >= 7.5
- NeoLine N3 browser extension (in the user’s browser)
npm install @smartargs/ngx-neolineimport { Component, inject } from '@angular/core';
import { NeolineService } from '@smartargs/ngx-neoline';
@Component({ selector: 'app-demo', template: '' })
export class DemoComponent {
private readonly neoline = inject(NeolineService);
async ngOnInit() {
const networks = await this.neoline.getNetworks();
console.log('chainId', networks.chainId);
}
}Expose structured debug logs from the service by providing a config flag at bootstrap (or feature-level providers).
// main.ts or app.config.ts
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app';
import { provideNeolineDebug } from '@smartargs/ngx-neoline';
bootstrapApplication(AppComponent, {
providers: [provideNeolineDebug(true)], // set false to disable
});Notes:
- Errors are always logged; debug logs are gated by the flag above.
- Ensure your browser console level is set to "Verbose" to see
console.debugoutput.
const sub = neoline.on('ACCOUNT_CHANGED').subscribe((e) => console.log(e));import { isNeolineError } from '@smartargs/ngx-neoline';
try {
await neoline.getNetworks();
} catch (err) {
if (isNeolineError(err)) {
console.error(err.type, err.description, err.data);
} else {
console.error(err);
}
}- Serve demo app:
npx nx serve ngx-neoline-project - Build library:
npx nx build libs
- Build outputs to
dist/libs/ libs/ng-package.jsonincludesREADME.mdandLICENSEas package assets
MIT. NeoLine is a separate product; this package only integrates with its public dAPI.
NeoLine N3 provider API: https://tutorial.neoline.io/reference/neo3-provider-api