Skip to content

Instantly share code, notes, and snippets.

@hal0x2328
hal0x2328 / genkey.js
Created November 9, 2021 12:28
Generate private key with neon-js
// npm i @cityofzion/neon-js@next for N3
const Neon = require('@cityofzion/neon-js')
const { wallet } = Neon
const account = new wallet.Account();
console.log(account.address);
console.log(account.WIF);
@hal0x2328
hal0x2328 / verify_tx_sig.py
Created October 6, 2021 09:01
Verify N3 transaction signature
#!/usr/bin/env python3
from neo3.network.payloads.transaction import Transaction
from neo3.core import cryptography
import binascii
import base64
import json
import sys
MAINNET=860833102
@hal0x2328
hal0x2328 / n3-disassemble.py
Last active January 24, 2022 15:25
N3 disassembler
# useful to disassemble an invocation script - won't work to
# disassemble an entire NEF because it will stop at the first RET
from neo3 import contracts, vm
import base64
class Disassembler(contracts.ApplicationEngine):
def pre_execute_instruction(self) -> None:
ins = self.current_context.current_instruction()
@hal0x2328
hal0x2328 / enumaccounts.py
Created January 5, 2020 14:20
Enumerate Neo accounts
#!/usr/bin/env python3
# enumaccounts.py - hal0x2328
# Read neo-cli LevelDB database and dump all accounts to JSON
import plyvel
import io
import binascii
import sys
import struct
@hal0x2328
hal0x2328 / combineprivkeys.py
Last active September 1, 2019 17:37
Python script to combine two Neo private keys into a third private key
#!/usr/bin/env python3
"""
combineprivkeys.py - by hal0x2328
This tool combines two private keys into a new private key, as part of
the "split-key" scheme used to generate vanity addresses without sharing
the private key with a third party generating the vanity address for you.
The party generating the vanity address only needs your public key. With it,
@hal0x2328
hal0x2328 / supplychain.cs
Created August 28, 2019 14:38
Simple Neo Supply Chain Smart Contract Example
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Services.Neo;
using Neo.SmartContract.Framework.Services.System;
// simple supply chain tracking contract example
namespace Neo.SmartContract
{
public struct TrackedItem
{
@hal0x2328
hal0x2328 / deserialize-raw.py
Created June 7, 2019 12:16
deserialize raw Neo transaction
#!/usr/bin/env python3
from neocore.IO.BinaryReader import BinaryReader
from neo.IO.MemoryStream import StreamManager
from neo.Core.TX.InvocationTransaction import InvocationTransaction
from neo.Core.TX.Transaction import Transaction
import binascii
import json
import io
@hal0x2328
hal0x2328 / scriptparser.py
Last active May 20, 2019 12:01
Neo invocation script parser
from neocore.Cryptography.Crypto import Crypto
from neocore.UInt160 import UInt160
from neo.VM.OpCode import *
import binascii
import json
import sys
import io
tokens = {}
with open('tokens.json') as t:
@hal0x2328
hal0x2328 / np-prompt-bytearray-argument-format
Created April 12, 2019 13:26
np-prompt bytearray argument format
sc invoke 0xe1d955a7a6c2c2af58eb2ea0abf28f3a2a9ee568 migrate [b'\x01\x1f\xc5\x6b\x6a\x00\x52\x7a\xc4\x6a\x51\x52\x7a\xc4\x68\x
16\x4e\x65\x6f\x2e\x53\x74\x6f\x72\x61\x67\x65\x2e\x47\x65\x74\x43\x6f\x6e\x74\x65\x78\x74\x61\x6a\x52\x52\x7a\xc4\x6a\x00\xc3\x03\
x61\x64\x64\x87\x64\x6e\x00\x06\x61\x64\x64\x69\x6e\x67\x68\x0f\x4e\x65\x6f\x2e\x52\x75\x6e\x74\x69\x6d\x65\x2e\x4c\x6f\x67\x6a\x52
\xc3\x6a\x51\xc3\x00\xc3\x7c\x68\x0f\x4e\x65\x6f\x2e\x53\x74\x6f\x72\x61\x67\x65\x2e\x47\x65\x74\x61\x6a\x53\x52\x7a\xc4\x6a\x53\xc
3\x6a\x51\xc3\x51\xc3\x93\x6a\x54\x52\x7a\xc4\x6a\x52\xc3\x6a\x51\xc3\x00\xc3\x6a\x54\xc3\x52\x72\x68\x0f\x4e\x65\x6f\x2e\x53\x74\x
6f\x72\x61\x67\x65\x2e\x50\x75\x74\x61\x6a\x54\xc3\x6c\x75\x66\x61\x6a\x00\xc3\x06\x72\x65\x6d\x6f\x76\x65\x87\x64\x54\x00\x6a\x52\
xc3\x6a\x51\xc3\x00\xc3\x7c\x68\x0f\x4e\x65\x6f\x2e\x53\x74\x6f\x72\x61\x67\x65\x2e\x47\x65\x74\x61\x6a\x53\x52\x7a\xc4\x6a\x52\xc3
\x6a\x51\xc3\x00\xc3\x6a\x53\xc3\x6a\x51\xc3\x51\xc3\x94\x52\x72\x68\x0f\x4e\x65\x6f\x2e\x53\x74\x6f\x72\
@hal0x2328
hal0x2328 / Dockerfile
Created January 11, 2019 19:20
Updated single Neo node Dockerfile
FROM microsoft/dotnet:runtime
RUN apt-get update \
&& apt-get install -y libleveldb-dev sqlite3 libsqlite3-dev libunwind8-dev unzip jq \
&& rm -rf /var/lib/apt/lists/*
RUN latest_tag=`curl -s https://api.github.com/repos/neo-project/neo-cli/releases/latest | grep tag_name | sed -E 's/.*"([^"]+)".*/\1/'` \
&& curl -vLO https://github.com/neo-project/neo-cli/releases/download/$latest_tag/neo-cli-linux-x64.zip && curl -vLO https://github.com/neo-project/neo-plugins/releases/download/$latest_tag/ApplicationLogs.zip && curl -vLO https://github.com/neo-project/neo-plugins/releases/download/$latest_tag/ImportBlocks.zip
RUN unzip neo-cli-linux-x64.zip && rm neo-cli-linux-x64.zip