Local Deployment with Neo-Express
Neo-Express provides a local Neo N3 blockchain for development. It supports single-node chains, account management, contract deployment, and method invocation.
Prerequisites
- Neo-Express installed (see Installation)
jqfor JSON inspection- A compiled contract (
.nef+.manifest.json)
Step 1: Create a Local Chain
NEOXP=./build/dotnet-tools/neoxp
# Create a fresh single-node chain
$NEOXP create -f -o chain.neo-expressThe -f flag forces overwrite if a chain file already exists.
Step 2: Fund the Deployer Account
Neo-Express creates a genesis account with all NEO and GAS. Transfer GAS to the deployer:
$NEOXP transfer -i chain.neo-express 100 GAS genesis node1This gives node1 enough GAS to cover deployment and invocation costs.
Step 3: Deploy the Contract
$NEOXP contract deploy -i chain.neo-express build/MyContract.nef node1The output includes:
contract-hash-- the deployed contract's script hashtx-hash-- the deployment transaction hash
To capture the contract hash programmatically:
DEPLOY_OUT="$($NEOXP contract deploy -i chain.neo-express build/MyContract.nef node1 -j)"
CONTRACT_HASH="$(echo "$DEPLOY_OUT" | jq -r '.["contract-hash"]')"
echo "Deployed at: $CONTRACT_HASH"Step 4: Invoke Methods
Create a .neo-invoke.json file for each invocation:
{
"contract": "0x<contract-hash>",
"operation": "methodName",
"args": [42, "hello"]
}Write invocation (creates a transaction, costs GAS):
$NEOXP contract invoke -i chain.neo-express invoke.neo-invoke.json node1Read-only invocation (no transaction, no GAS cost):
$NEOXP contract invoke -r -j -i chain.neo-express invoke.neo-invoke.json node1The -r flag runs the invocation as a test (read-only). The -j flag outputs JSON for programmatic parsing.
Step 5: Verify Transaction Results
After a write invocation, inspect the transaction's application log:
TX_HASH="0x<transaction-hash>"
$NEOXP show transaction -i chain.neo-express "$TX_HASH"Check the VM state and notifications:
APP_LOG="$($NEOXP show transaction -i chain.neo-express "$TX_HASH")"
# VM state should be "HALT" (success)
echo "$APP_LOG" | jq '.["application-log"].executions[0].vmstate'
# Check emitted events
echo "$APP_LOG" | jq '.["application-log"].executions[0].notifications'