nexus contract deploy
Deploy a WASM smart contract to NEXUS.
nexus contract deploy [OPTIONS]
Options
| Option | Required | Description |
|---|
--wasm <PATH> | Yes | Path to WASM file |
--name <NAME> | Yes | Contract name |
--from <ADDRESS> | Yes | Deployer address or wallet name |
--init-args <HEX> | No | Initialization arguments (hex) |
--value <SATS> | No | Value to transfer (satoshis) |
Examples
# Basic deployment
nexus contract deploy \
--wasm ./target/wasm32-unknown-unknown/release/counter.wasm \
--name counter \
--from my-wallet
# With initialization arguments
nexus contract deploy \
--wasm ./token.wasm \
--name my_token \
--from my-wallet \
--init-args "0x4d79546f6b656e,4d544b,12,3b9aca00"
# With value transfer
nexus contract deploy \
--wasm ./vault.wasm \
--name vault \
--from my-wallet \
--value 10000
Output
Deploying contract...
→ Using wallet: my-wallet
✓ Contract deployed!
Contract ID: a1b2c3d4e5f6...
nexus contract call
Call a contract function.
nexus contract call [OPTIONS]
Options
| Option | Required | Description |
|---|
--contract <ID> | Yes | Contract ID (hex) |
--function <NAME> | Yes | Function name |
--from <ADDRESS> | Yes | Caller address or wallet name |
--args <HEX> | No | Function arguments (hex) |
--commit | No | Execute as state-changing transaction |
--format <FMT> | No | Output format: auto, hex, utf8, u32, u64, address |
--value <SATS> | No | Value to transfer (satoshis) |
Examples
# View call (read-only)
nexus contract call \
--contract a1b2c3d4... \
--function get_count \
--from my-wallet
# With arguments
nexus contract call \
--contract a1b2c3d4... \
--function balance_of \
--args "0x1234567890abcdef..." \
--from my-wallet \
--format u64
# State-changing call
nexus contract call \
--contract a1b2c3d4... \
--function increment \
--from my-wallet \
--commit
# Transfer with value
nexus contract call \
--contract a1b2c3d4... \
--function deposit \
--from my-wallet \
--value 5000 \
--commit
| Format | Description |
|---|
auto | Auto-detect based on result length |
hex | Raw hexadecimal |
utf8 | UTF-8 string |
u32 | 32-bit unsigned integer |
u64 | 64-bit unsigned integer |
address | Bitcoin address (P2PKH or P2TR) |
Output
→ Calling contract function (View)...
✓ Call successful!
Result (typed): 42
Result (hex): 2a00000000000000
nexus contract info
Get contract information.
nexus contract info <CONTRACT_ID>
Example
nexus contract info a1b2c3d4e5f6...
Output
ℹ Contract Information
Contract ID: a1b2c3d4e5f6...
Argument Encoding
Contract arguments are passed as hex-encoded bytes. Here’s how to encode common types:
Integers
# u32 (4 bytes, little-endian)
# Value: 100 = 0x64
--args "0x64000000"
# u64 (8 bytes, little-endian)
# Value: 1000000 = 0x0F4240
--args "0x40420f0000000000"
Addresses
# 32-byte x-only public key
--args "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
Strings
# UTF-8 encoded
# "Hello" = 0x48656c6c6f
--args "0x48656c6c6f"
Multiple Arguments
Concatenate hex values:
# transfer(to: address, amount: u64)
# to = 0x1234...5678 (32 bytes)
# amount = 1000 (8 bytes)
--args "0x1234...5678e803000000000000"
JSON Arguments
For contracts that accept JSON arguments:
# NEP-20 init: ["TokenName", "TKN", "18", "1000000"]
nexus contract deploy \
--wasm ./token.wasm \
--name token \
--from my-wallet \
--init-args "0x$(echo -n '["MyToken","MTK","18","1000000"]' | xxd -p)"
Tips
Use --format to get human-readable output for known return types.
Always use --commit for state-changing operations. Without it, the call is read-only.
Contract IDs are 32-byte hex strings (64 characters).