Interacting with AE in Erlang

I’m working on a prototype of a system that’s going to be written in Erlang.

A part of the system needs to interact with AE. What is the best way to do this from Erlang?

6 Likes

You can build and run aeternity “like any other” erlang application and call functions inside its modules. A good hint would be looking at the commands being ran when starting the node, in the corresponding script. Using that, you can just start an aeternity node inside your erlang shell like any other Erlang/OTP app.

2 Likes

Hi @zkvonsnarkenstein.chain

I am happy to hear your plans to build on top of the node itself. For that there is support for somewhat hacky plugin system: it allows you to run the node as an application. It needs more care and it is not that trivial to use, so I summon @uwiger to elaborate here.

The MDW already uses it, so it is totally doable, the devil is in the details.

5 Likes

Hi, @zkvonsnarkenstein.chain ! Can you tell me a little about what your system is intended to do? I’m working on a node launcher and activity reporter application myself, also in Erlang, and have similar needs in terms of communicating with the core Aeternity applications from within the same node. I intend to simplify a few things about the startup procedure to make this easier (and make it easier to document), so I’d like to know a little about your project because I might give me more ideas or clarify my own thinking about exactly how the startup could be more usefully structured (for example, make it easier to bring in as a dependency, or start with additional/alternative tooling to make interoperation more accessible).

4 Likes

What the system will do is, in short, to hold and replicate files among nodes. The AE blockchain will be used for pointers to files and integrety checks. So the app needs to be able to deploy and interact with smart comtracts.

5 Likes

For that kind of basic interaction with the protocol, I would recommend to stick to APIs and SDKs still. Of course it would make sense to talk directly in erlang, the issue is though that some data needs some formatting, which is done by the SDK(s). Or to put it in more detail: While reading operations (getting data from chain) can theoretically be done, writing data certainly needs signing and so on.

So the way to go would be: The call data for performing reads or sending transactions is being generated by the compiler, whose API takes fairly simple requests. Passing that along to the node to perform a read operation (local contract call ) shouldn’t be too big of a deal.

For sending transactions though, they need to have the right format and signed. The SDKs take care of that, normally. And there is documentation on the specs for this of course, but maybe @hanssv.chain can point to tests, where such a transaction is constructed and signed using purely erlang ?

4 Likes

It would be great to have an erlang way to sign transactions, maybe a convenience method to make it easier for Erlang developers. Currently I’m calling aecli through system calls which is a shame, but works for my purpose so far. I’m trying to understand the ae source test suites for using aeternity_source/apps/aecore/test/aec_test_utils.erl line 666

Without knowing exactly what you are trying to do it sounds like GitHub - aeternity/Vanillae: Ecommerce toolkit for interacting with the Aeternity blockchain as a payment solution might be the right thing?

3 Likes

I’m trying to sign and publish contract call transactions from Erlang https://github.com/jagguli/DamageBDD/blob/master/src/damage_accounts.erl#L375

I’m using this contract for account management and hope to expand it to use it for paying out for testing infrastructure.

Yes I’m using Vanillae, I guess the functions for signing tx is still in development, eager to test it out. Thanks.