Minka Ledger Docs
ReferencesApi referenceEffectEffects

Create an effect

Effects describe behaviors that can be triggered because of a change in the ledger data. Effects are the main mechanism for adding new functionality to ledgers that is use case specific. Each change in ledger data structures broadcasts an event that can be used to notify external systems through effects. Event is identified by a signal - one of the predefined names provided by the Ledger: - `balance-received` - raised when wallet receives a balance - `effect-created` - raised when a new effect is created - `intent-created` - raised when a new intent is created - `signer-created` - raised when a new effect is created - `symbol-created` - raised when a new symbol is created - `wallet-created` - raised when a new wallet is created Each effect is registered for specific event signal. It also has a filter which allows for more granular control of conditions that are going to trigger event forwarding. Filter can be used to select only certain events based on the event data. Effect action defines how to forward the events to external systems or ledger plugins. For example calling the external system through webhooks. Currently only one mechanism is supported: - `webhook` - call an external system through webhooks

POST
/effects

Authorization

AuthorizationRequiredBearer <token>

JWT signed by private key. The presence of this token is not mandatory. It becomes required through the configuration of authorization access rules that requires a token to grant access. Once sent, the token is validated for its format, signature and expiration, regardless of the presence of access rules.

In: header

Request Body

application/jsonRequired

Effect body

hashRequiredstring
Pattern: "^[A-Fa-f0-9]{64}$"
metaRequiredobject
dataRequiredobject & object

Header Parameters

x-ledgerstring | string

The unique identifier of ledger in context for multi tenant requests.

curl -X POST "http://localhost:3000/v2/effects" \
  -H "x-ledger: bog" \
  -H "Content-Type: application/json" \
  -d '{
    "hash": "4969e3c012b66d88cec597bf337fc01eab8d651e6ed2d5c40236cc1f7d93435a",
    "meta": {
      "proofs": [
        {
          "method": "ed25519-v2",
          "public": "WAweF9PHlboQoW0z8NqhZXFmzUTaV74NRFAd/aILprE=",
          "digest": "4969e3c012b66d88cec597bf337fc01eab8d651e6ed2d5c40236cc1f7d93435a",
          "result": "0G2gvSfBx6MwPT8ShBaiYx7zwa5Kqc4Cq3S3NXV1m5/ZPozoH/SUouuhi9sQU+f0yo0eX4ygH7PzE3PAdlxsCQ==",
          "custom": {
            "moment": "2019-01-01T00:00:00.000Z",
            "type": "PERSON",
            "reference": 3284759238475
          }
        }
      ]
    },
    "data": {
      "handle": "tran:12345@pbz.hr",
      "parent": "4969e3c012b66d88cec597bf337fc01eab8d651e6ed2d5c40236cc1f7d93435a",
      "access": [
        {
          "signer": {
            "format": "ed25519-raw",
            "public": {
              "$eq": "WAweF9PHlboQoW0z8NqhZXFmzUTaV74NRFAd/aILprE="
            },
            "custom": {
              "type": "person",
              "age": {
                "$gte": 21
              }
            },
            "handle": {
              "$in": [
                "admin"
              ]
            }
          },
          "record": "any",
          "action": "any",
          "invoke": "wallet.canSpendAllChangedRouteTargets",
          "bearer": {
            "iss": "company.org",
            "sub": "admin",
            "aud": "ledger",
            "hsh": true,
            "$signer": {
              "format": "ed25519-raw",
              "public": {
                "$eq": "WAweF9PHlboQoW0z8NqhZXFmzUTaV74NRFAd/aILprE="
              },
              "custom": {
                "type": "person",
                "age": {
                  "$gte": 21
                }
              },
              "handle": {
                "$in": [
                  "admin"
                ]
              }
            }
          },
          "filter": {
            "schema": "bank"
          },
          "change": {
            "schema": "p2p"
          }
        }
      ],
      "custom": {
        "type": "PERSON",
        "reference": 3284759238475
      },
      "schema": "tran:12345@pbz.hr",
      "signal": "anchor-created",
      "filter": {
        "wallet.data.handle": "bank1"
      },
      "action": {
        "schema": "webhook",
        "endpoint": "http://bank1.minkainc.dev/webhook/balance-received"
      }
    }
  }'

Created effect

{
  "hash": "4969e3c012b66d88cec597bf337fc01eab8d651e6ed2d5c40236cc1f7d93435a",
  "meta": {
    "proofs": [
      {
        "method": "ed25519-v2",
        "public": "WAweF9PHlboQoW0z8NqhZXFmzUTaV74NRFAd/aILprE=",
        "digest": "4969e3c012b66d88cec597bf337fc01eab8d651e6ed2d5c40236cc1f7d93435a",
        "result": "0G2gvSfBx6MwPT8ShBaiYx7zwa5Kqc4Cq3S3NXV1m5/ZPozoH/SUouuhi9sQU+f0yo0eX4ygH7PzE3PAdlxsCQ==",
        "custom": {
          "moment": "2019-01-01T00:00:00.000Z",
          "type": "PERSON",
          "reference": 3284759238475
        }
      }
    ],
    "owners": [
      "WAweF9PHlboQoW0z8NqhZXFmzUTaV74NRFAd/aILprE="
    ],
    "moment": "2019-08-24T14:15:22Z",
    "status": "string",
    "labels": [
      "preferred"
    ]
  },
  "luid": "$wlt.7mSVWFKX-Tfx2NsNj",
  "data": {
    "handle": "tran:12345@pbz.hr",
    "parent": "4969e3c012b66d88cec597bf337fc01eab8d651e6ed2d5c40236cc1f7d93435a",
    "access": [
      {
        "signer": {
          "format": "ed25519-raw",
          "public": {
            "$eq": "WAweF9PHlboQoW0z8NqhZXFmzUTaV74NRFAd/aILprE="
          },
          "custom": {
            "type": "person",
            "age": {
              "$gte": 21
            }
          },
          "handle": {
            "$in": [
              "admin"
            ]
          }
        },
        "record": "any",
        "action": "any",
        "invoke": "wallet.canSpendAllChangedRouteTargets",
        "bearer": {
          "iss": "company.org",
          "sub": "admin",
          "aud": "ledger",
          "hsh": true,
          "$signer": {
            "format": "ed25519-raw",
            "public": {
              "$eq": "WAweF9PHlboQoW0z8NqhZXFmzUTaV74NRFAd/aILprE="
            },
            "custom": {
              "type": "person",
              "age": {
                "$gte": 21
              }
            },
            "handle": {
              "$in": [
                "admin"
              ]
            }
          }
        },
        "filter": {
          "schema": "bank"
        },
        "change": {
          "schema": "p2p"
        }
      }
    ],
    "custom": {
      "type": "PERSON",
      "reference": 3284759238475
    },
    "schema": "tran:12345@pbz.hr",
    "signal": "anchor-created",
    "filter": {
      "wallet.data.handle": "bank1"
    },
    "action": {
      "schema": "webhook",
      "endpoint": "http://bank1.minkainc.dev/webhook/balance-received"
    }
  }
}