How to get local node instance from shell? - Solved


We have a running local daemon.
A client wasm app in the browser requires an orbit-db connection. To create new OrbitDB instance we need coreapi.CoreAPI param.

// NewOrbitDB Creates a new OrbitDB instance with default access controllers and store types
func NewOrbitDB(ctx context.Context, i coreapi.CoreAPI, options *NewOrbitDBOptions) (iface.OrbitDB, error) {

We can not create a new node because ipfs can not use wasm target.

node, err := core.NewNode(ctx, nodeOptions)
if err != nil {
       return nil, err

// Attach the Core API to the constructed node
return coreapi.NewCoreAPI(node)

We can create a new shell though:

// Where your local node is running on localhost:5001
sh := shell.NewShell("localhost:5001")

There is a method to get the peer id:

Is it possible to get *core.ipfsNode instance from the shell?

P.S. It was suggested to use GitHub - ipfs/go-ipfs-http-client: Go-IPFS API implementation over HTTP API instead.

It seems to be working in the following way:

c, err := client.NewURLApiWithClient("localhost:5001", &http.Client{})
if err != nil {
	panic(fmt.Errorf("failed to connect to local api: %s", err))