neo-js-sdk
v0.2.3
Published
Neo N3 JavaScript/TypeScript SDK — successor to neo-js (no longer maintained). Typed models, object-based RPC inputs, full N3 RPC coverage.
Maintainers
Readme
neo-js-sdk
Neo N3 JavaScript/TypeScript SDK with a typed RPC client, core transaction primitives, and NEP-2 / NEP-6 wallet helpers.
What It Includes
- Neo N3 network constants and native contract hash helpers
H160/H256hash wrappers- Binary serialization helpers
PrivateKey,PublicKey,Witness,Signer,Tx,Header,Block,TrimmedBlockScriptBuilder,OpCode,CallFlags- NEP-2 helpers and NEP-6 wallet/account models
- Typed JSON-RPC coverage across core, state-service, and wallet-node methods with modeled outputs and object-based inputs
- A single canonical
camelCaseAPI surface for JavaScript and TypeScript consumers
Install
npm install neo-js-sdkVerification
npm run typecheck
npm test
npm run buildOptional live RPC smoke test against Neo testnet:
npm run test:integrationOverride the default testnet endpoint if needed:
NEO_RPC_URL=https://your-rpc-node npm run test:integrationUsage
import {
CallFlags,
InvokeParameters,
PrivateKey,
RpcClient,
ScriptBuilder,
Signer,
Tx,
WitnessScope,
gasContractHash,
testNetworkId
} from "neo-js-sdk";
const privateKey = new PrivateKey(
"f046222512e7258c62f56f5e9e624d08c8dc38f336a15f320b3501ec7e90d7c6"
);
const script = new ScriptBuilder()
.emitContractCall(gasContractHash(), "transfer", CallFlags.All, [
"from",
"to",
1
])
.toBytes();
const tx = new Tx({
nonce: 1,
systemFee: 1_0000000n,
networkFee: 1_0000000n,
validUntilBlock: 100,
script,
signers: [
new Signer({
account: privateKey.publicKey().getScriptHash(),
scopes: WitnessScope.CalledByEntry
})
]
});
tx.witnesses = [privateKey.signWitness(tx.getSignData(testNetworkId()))];
const client = new RpcClient("https://seed1t5.neo.org:20332");
await client.sendRawTransaction({ tx });
const invoke = await client.invokeFunction({
contractHash: gasContractHash(),
method: "balanceOf",
args: new InvokeParameters().addHash160(privateKey.publicKey().getScriptHash())
});Wallet Helpers
import { Wallet } from "neo-js-sdk";
const wallet = new Wallet({ name: "demo", passphrase: "secret" });
const account = wallet.createAccount();
wallet.writeToFile("./wallet.json");
const reopened = Wallet.openNep6Wallet("./wallet.json");
reopened.decrypt("secret");Development
npm run typecheck
npm test
npm run build
npm run test:integration