Web3 calls

Hey everyone, just wanted to stamp this in the forum, up to this point I have not seen anyone post on this topic.

We have an existing web3 game and have made a web2 game with nakama. We are now working out different solutions to interface securely from RPCs to Web3. If you are interested in this topic, feel free to connect with us, we are always looking to discuss with other teams and people working in the same problem space as us. If we discover anything of significance, we will continue to add on this thread

thanks !

We started down this path (integrating Web3 libs directly into nakama), but found it to be cleaner to pull all our Web3 interaction into another service, written in JS. Then Nakama calls that server behind the scenes. This lets us do a few things:

  1. Use simple libs like viem.
  2. Further sandbox our private keys (the JS service is not public).
  3. Wrap all the asynchronous Web3 transactions with a simple service that calls some RPC webhooks on Nakama. This makes the Nakama code much simpler.
  4. Not have to worry about synchonizing async stuff across multiple nodes of a Nakama cluster.

Anyway, just two cents.

1 Like

Excellent, appreciate this, feel like sometimes we are just an island and swimming around in a circle by ourselves lol… this is exactly the approach we are tinkering with… using some php web3 libs at the moment, seem to be working.

Internal + secure, concerns are separated and outside nakama for now, the RPC interface works great. We are also doing that for a Coinbase checkout, with a webhook callback, shapes the incoming data and then system call the RPC to update a player wallet

Viem, not heard of that, appreciate pointing that out, very helpful :slight_smile:

Look forward to hearing from others in this thread, different approaches

1 Like

We ditched the web3.php solution lol, it was not easy to figure out… and instead are now using express on localhost with ethers and it is way easier and consistent :slight_smile:

How do you guys handle a long call from the nakama-js client ?

For example, I have an RPC that sends a request to chain and takes about 20s to return. In the meantime, my JS client is telling me

Even though in the API explorer, it waits and then returns a success message with no issue.

Sorry @ryanprice , I wasn’t watching this thread. Feel free to connect on X if you’d like (x.com). In general, with operations that take longer than, say 500ms, we switch to polling or socket notifs.

Specifically, we have Nakama send a request to our backend, then return immediately. It also starts a goroutine that polls our backend to look for blockchain confirmation. Once confirmed, it sends a notif to the client.

1 Like

I went ahead and wrote a little more extensively about our approach if anyone is interested. See: Nakama, Meet Blockchain. How we’re connecting Nakama to the… | by Benjamin Jordan | Spyre.io | Sep, 2024 | Medium

2 Likes