I have an idea for an IXI module that I'd like to try out, but I don't understand how I'm supposed to implement it.
I'd like to start with an example; what would an "Hello world!" version of an IXI module look like?
I have an idea for an IXI module that I'd like to try out, but I don't understand how I'm supposed to implement it.
I'd like to start with an example; what would an "Hello world!" version of an IXI module look like?
ixi/hello_world/package.json
{"main": "index.js"}
ixi/hello_world/index.js
function hello_world_impl(req) {
return com.iota.iri.service.dto.IXIResponse.create({greeting: "Hello, world!"});
}
API.put("helloWorld", new com.iota.iri.service.CallableRequest({call: hello_world_impl}));
How to call:
curl http://localhost:14700 -X POST -H 'X-IOTA-API-Version: 1.4.1' -H 'Content-Type: application/json' -d '{"command": "hello_world.helloWorld"}'
Reply:
{"ixi":{"greeting":"Hello, world!"},"duration":2}
There is also Snapshot.ixi for a more realistic example.
Exception during IOTA node initialisation: --- java.lang.NullPointerException: null --- at com.iota.iri.IXI.attach(IXI.java:249) ~[iri.jar:na] --- at com.iota.iri.IXI.loadModule(IXI.java:223) ~[iri.jar:na]
– Daniel F
Dec 21 '17 at 08:22
Neighbor stats extension started...
printed into the log, but then it crashed. So I believe that it has the JavaScript engine enabled.
– Daniel F
Dec 21 '17 at 13:32
rm -rf
. See https://github.com/iotaledger/iri/issues/426#issuecomment-353566453 . It's working now :)
– Daniel F
Dec 22 '17 at 17:33