Functions and tooling for NEO in Clojure, using the NEO core codebase.
Aims to add extra functionality to neo-cli
and make interaction with
the blockchain more easy and fun.
The code is in active development, pre-alpha. It should not be used for anything critical. Please only use it in a private blockchain environment for now.
The following functionality is included:
- Create and load wallets
- Claim gas for wallet
- Sync blockchain over RPC
- Claim initial NEO from genesis block
- Deploy smart contracts
- Invoke smart contracts
- Make transactions
- Run an RPC server with extended commands
- Keep track of assets
It’s hightly recommended to use the Docker image when running the project, as setting up Clojure CLR with NEO can be tricky. Make sure you have Docker 17.05 or above installed, then run the following commands:
$ git clone https://github.com/effectai/neo-clojure-clr $ cd neo-clojure-clr $ docker build . -t neo-clj-clr $ docker run --rm -it neo-clj-clr REPL 0.0.0.0:11217 user>
This leaves you with a Clojure REPL in user namespace.
The application assumes you have neo-privatenet-docker running
with an RPC server enabled on http://localhost:10332
.
To interact with the blockchain you’ll need to load some namespaces. The examples below will assume the following setup:
user> (require '[neo-clj.core :as neo-clj])
user> (require '[neo-clj.blockchain :as bc])
user> (require '[neo-clj.rpc :as rpc])
user> (require '[neo-clj.wallet :as wallet])
user> (def b (bc/create))
#'user/b
user> (bc/sync b)
load block 0 of 1534
...
...
load block 1534 of 1534
nil
user> (def w (wallet/create "wallet.db3" "pass"))
#'user/w
user> (def to (wallet/get-a-public-key w))
#'user/to
user> (def claim-tx (neo-clj/claim-initial-neo-tx to))
#'user/claim-tx
user> (bc/relay (:ctx claim-tx))
true
user> (bc/sync b)
...
...
user> (wallet/neo-balance w)
100000000
user> (def server (rpc/create-server {:port 10336}))
#'user/server
user> (rpc/start-server server)
Starting extended RPC server on port 10336
The RPC server exposes the same methods as in the neo core server. In
addition the following endpoints are available in neo-clj
:
command | parameters | description |
---|---|---|
getassets | list all registered assets | |
getkeys | get all keys in rpc wallet | |
makekeys | <num> (optional) | add <num> new keys in rpc wallet |
claimgas | <address> (optional) | claim gas for rpc wallet. if address is omitted, all addresses are used |