Definition
Post a definition to create an autonomous agent.

Arguments

  • address string required Address of the definition
  • definition array required Definition of the autonomous agent

Returns

Returns the unit hash.

Example

1
const { Client, utils } = require('obyte');
2
3
const client = new Client('wss://obyte.org/bb-test', { testnet: true });
4
5
const definition = [
6
'autonomous agent',
7
{
8
bounce_fees: {
9
base: 10000
10
},
11
messages: [
12
{
13
app: 'payment',
14
payload: {
15
asset: 'base',
16
outputs: [
17
{
18
address: "{trigger.address}",
19
amount: "{trigger.output[[asset=base]] - 1000}"
20
}
21
]
22
}
23
}
24
]
25
}
26
];
27
28
const params = {
29
address: utils.getChash160(definition),
30
definition
31
}
32
33
client.post.definition(params, wif, function(err, result) {
34
if (err) return console.error(err);
35
console.log(result);
36
});
Copied!
The above example of an AA just sends the received money less 1000 bytes back to the sender.

Learn more

Last modified 7mo ago