obyte.js
GitHubDiscord
0.1.6
0.1.6
  • Obyte.js
  • Getting started
    • Quick start
    • Testnet
  • Client
    • Subscribe
    • Just saying
  • API
    • Get witnesses
    • Get peers
    • Get joint
    • Get last MCI
    • Get history
    • Get attestation
    • Get attestations
    • Get bots
    • Get asset metadata
    • Get definition
    • Get balances
    • Get profile units
    • Dry run AA (testnet)
    • Get AA state vars (testnet)
    • Core
      • Catchup
      • Get hash tree
      • Get light props
      • Post joint
      • Pick divisible coins for amount
      • Heartbeat
  • Post
    • Address definition change
    • Attestation
    • Asset
    • Asset attestors
    • Data
    • Data feed
    • Definition
    • Definition template
    • Payment
    • Poll
    • Vote
    • Profile
    • Text
  • Utils
    • Generate a random address
    • Get definition address
    • Is valid address
    • Keep connection alive
  • About
    • About
    • Links
    • Tutorials
Powered by GitBook
On this page
  • Arguments
  • Returns
  • Example
  • Learn more
  1. Post

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

const { Client, utils } = require('obyte');

const client = new Client('wss://obyte.org/bb-test', { testnet: true });

const definition = [
  'autonomous agent',
  {
    bounce_fees: {
      base: 10000
    },
    messages: [
      {
        app: 'payment',
        payload: {
          asset: 'base',
          outputs: [
            {
              address: "{trigger.address}",
              amount: "{trigger.output[[asset=base]] - 1000}"
            }
          ]
        }
      }
    ]
  }
];

const params = {
  address: utils.getChash160(definition),
  definition
}

client.post.definition(params, wif, function(err, result) {
  console.log(result);
});

The above example of an AA just sends the received money less 1000 bytes back to the sender.

Learn more

PreviousData feedNextDefinition template

Last updated 5 years ago

"Getting started guide":

"Oscript language reference":

https://developer.obyte.org/autonomous-agents/getting-started-guide
https://developer.obyte.org/autonomous-agents/oscript-language-reference