@r3e/neo-js
v0.1.8
Published
Neo N3 JavaScript SDK inspired by r3e-network/neo-python-sdk with expanded RPC coverage.
Maintainers
Readme
@r3e/neo-js
Neo N3 JavaScript/TypeScript SDK inspired by r3e-network/neo-python-sdk and extended with a broader typed RPC surface.
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- Async NEP-2 helpers and NEP-6 wallet/account models
- Typed JSON-RPC client with Python-parity methods plus broader official Neo N3 RPC coverage, including state-service methods like
getProof/getState/findStatesand wallet-node methods likeopenWallet,sendFrom, andsendMany
Install
npm install @r3e/neo-jsVerification
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 "@r3e/neo-js";
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.sendTx(tx);
const invoke = await client.invokeFunction(
gasContractHash(),
"balanceOf",
new InvokeParameters().addHash160(privateKey.publicKey().getScriptHash())
);Wallet Helpers
import { Wallet } from "@r3e/neo-js";
const wallet = new Wallet({ name: "demo", passphrase: "secret" });
const account = await wallet.createAccount();
await wallet.writeToFile("./wallet.json");
const reopened = await Wallet.openNep6Wallet("./wallet.json");
await reopened.decrypt("secret");Development
npm run typecheck
npm test
npm run build
npm run test:integration