Documentation ¶
Overview ¶
Go-nitro can be run as a system service with an RPC api. Go-nitro's default configuration looks for a local blockchain network on port 8545 with chainid 1337. If such a network is available is running, go-nitro can be started from the root directory with
go run .
Or, built to an executable binary with
go build -o gonitro
Either command may be augmented with a build tag like so:
go build -o gonitro -tags embed-ui
which will cause a static website located at packages/nitro-gui/dist to be served over the rpcPort (see below). If no such site has been built, there will be a compiler error.
Go nitro accepts the following command flags, which can also be displayed via `go run . -help` (or `gonitro -help` for the build binary). Usage of ./nitro-rpc-server:
-chainid int Specifies the chain id of the chain. (default 1337) -chainurl string Specifies the url of a RPC endpoint for the chain. (default "ws://127.0.0.1:8545") -deploycontracts Specifies whether to deploy the adjudicator and create2deployer contracts. -msgport int Specifies the tcp port for the message service. (default 3005) -naaddress string Specifies the address of the nitro adjudicator contract. Default is the address computed by the Create2Deployer contract. (default "0xC6A55E07566416274dBF020b5548eecEdB56290c") -pk string Specifies the private key used by the node. Default is Alice's private key. (default "2d999770f7b5d49b694080f987b82bbc9fc9ac2b4dcc10b0f8aba7d700f69c6d") -rpcport int Specifies the tcp port for the rpc server. (default 4005) -usedurablestore Specifies whether to use a durable store or an in-memory store. -usenats Specifies whether to use NATS or http/ws for the rpc server.
You can make remote procedure calls like so:
curl -X POST \ -H 'Content-Type: application/json' \ -d '{"jsonrpc":"2.0","id":1,"method":"get_address","params":{}}' \ http://localhost:4005/api/v1
but see github.com/statechannels/go-nitro/rpc or https://github.com/statechannels/go-nitro/tree/main/packages/nitro-rpc-client for an RPC client to do so programmatically.
Directories ¶
Path | Synopsis |
---|---|
Package abi contains constants which are useful when performing abi encoding and decoding.
|
Package abi contains constants which are useful when performing abi encoding and decoding. |
Package channel defines types and methods for state channels.
|
Package channel defines types and methods for state channels. |
consensus_channel
Package consensus_channel manages a running ledger channel.
|
Package consensus_channel manages a running ledger channel. |
state
Package state defines the data structures which are signed by channel participants.
|
Package state defines the data structures which are signed by channel participants. |
state/outcome
Package outcome defines the data structures for expressing how channel funds are to be distributed on-chain.
|
Package outcome defines the data structures for expressing how channel funds are to be distributed on-chain. |
cmd
|
|
Package crypto contains types and functions for creating Ethereum private keys and accounts, and creating/recovering signatures made with such keys.
|
Package crypto contains types and functions for creating Ethereum private keys and accounts, and creating/recovering signatures made with such keys. |
internal
|
|
safesync
package safesync provides a type-safe, concurrency-safe Map struct
|
package safesync provides a type-safe, concurrency-safe Map struct |
testactors
Package testactors exports peers with vanity addresses: with corresponding keys, names and virtual funding protocol roles.
|
Package testactors exports peers with vanity addresses: with corresponding keys, names and virtual funding protocol roles. |
testhelpers
Package testhelpers contains functions which pretty-print test failures.
|
Package testhelpers contains functions which pretty-print test failures. |
Package node contains imperative library code for running a go-nitro node inside another application.
|
Package node contains imperative library code for running a go-nitro node inside another application. |
engine
Package engine contains the types and imperative code for the business logic of a go-nitro Node.
|
Package engine contains the types and imperative code for the business logic of a go-nitro Node. |
engine/chainservice
Package chainservice is a chain service responsible for submitting blockchain transactions and relaying blockchain events.
|
Package chainservice is a chain service responsible for submitting blockchain transactions and relaying blockchain events. |
engine/chainservice/adjudicator
package NitroAdjudicator contains bindings generated from the Nitro Adjudicator solidity contract, as well as utilities for converting client types to on-chain types.
|
package NitroAdjudicator contains bindings generated from the Nitro Adjudicator solidity contract, as well as utilities for converting client types to on-chain types. |
engine/messageservice
Package messageservice is a messaging service responsible for routing messages to peers and relaying messages received from peers.
|
Package messageservice is a messaging service responsible for routing messages to peers and relaying messages received from peers. |
engine/store
Package store contains the interface for a go-nitro store.
|
Package store contains the interface for a go-nitro store. |
Package protocols defines the off-chain protocols for managing channels.
|
Package protocols defines the off-chain protocols for managing channels. |
directdefund
Package directdefund implements an off-chain protocol to defund a directly-funded channel.
|
Package directdefund implements an off-chain protocol to defund a directly-funded channel. |
directfund
Package directfund implements an off-chain protocol to directly fund a channel.
|
Package directfund implements an off-chain protocol to directly fund a channel. |
virtualfund
Package virtualfund implements an off-chain protocol to virtually fund a channel.
|
Package virtualfund implements an off-chain protocol to virtually fund a channel. |
Package rand is a convenience wrapper aroung golang rand go math/rand is deterministic unless a random seed is provided see https://gobyexample.com/random-numbers
|
Package rand is a convenience wrapper aroung golang rand go math/rand is deterministic unless a random seed is provided see https://gobyexample.com/random-numbers |
Package types defines common types.
|
Package types defines common types. |