https://github.com/effectai/neo-clojure-clr
Clojure CLR functions for interactive development on the NEO blockchain
https://github.com/effectai/neo-clojure-clr
Last synced: 3 months ago
JSON representation
Clojure CLR functions for interactive development on the NEO blockchain
- Host: GitHub
- URL: https://github.com/effectai/neo-clojure-clr
- Owner: effectai
- License: mit
- Created: 2017-11-27T23:00:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-18T16:41:03.000Z (over 8 years ago)
- Last Synced: 2025-04-22T05:04:44.475Z (about 1 year ago)
- Language: Clojure
- Homepage:
- Size: 86.9 KB
- Stars: 5
- Watchers: 5
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
* Clojure CLR - NEO
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.
** Status
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.
** Features
The following functionality is included:
- [[#create-a-wallet][Create and load wallets]]
- Claim gas for wallet
- [[#load-and-sync-blockchain][Sync blockchain over RPC]]
- [[#claim-initial-neo][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
** Getting Started
*** Installation
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:
#+BEGIN_SRC
$ 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>
#+END_SRC
This leaves you with a Clojure REPL in user namespace.
*** Setup
The application assumes you have [[https://github.com/CityOfZion/neo-privatenet-docker][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:
#+BEGIN_SRC clojure
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])
#+END_SRC
** Examples
**** Load and sync blockchain
#+BEGIN_SRC clojure
user> (def b (bc/create))
#'user/b
user> (bc/sync b)
load block 0 of 1534
...
...
load block 1534 of 1534
nil
#+END_SRC
**** Create a wallet
#+BEGIN_SRC clojure
user> (def w (wallet/create "wallet.db3" "pass"))
#'user/w
#+END_SRC
**** Claim initial NEO
#+BEGIN_SRC clojure
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
#+END_SRC
**** Start an RPC server
#+BEGIN_SRC clojure
user> (def server (rpc/create-server {:port 10336}))
#'user/server
user> (rpc/start-server server)
Starting extended RPC server on port 10336
#+END_SRC
** RPC reference
The RPC server exposes the same [[https://github.com/neo-project/neo/wiki/API-Reference][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 | (optional) | add new keys in rpc wallet |
| claimgas |
(optional) | claim gas for rpc wallet. if address is omitted, all addresses are used |