Skip to content

Latest commit

 

History

History
115 lines (78 loc) · 2.77 KB

API.md

File metadata and controls

115 lines (78 loc) · 2.77 KB

Table of Contents

Binding

Type: Object

Properties

  • type string The type of the binding (a valid Radspec type)
  • value any The value of the binding

Bindings

Type: Object<string, Binding>

radspec

evaluateRaw

Evaluate a radspec expression with manual bindings.

Parameters

  • source string The radspec expression
  • bindings Bindings An object of bindings and their values
  • evaluatorOptions Object? An options object for the evaluator

Examples

import radspec from 'radspec'

radspec.evaluateRaw('a is `a`', {
  a: { type: 'int256', value: 10 }
}).then(console.log)

Returns Promise<string> The result of the evaluation

evaluate

Evaluate a radspec expression (source) for a transaction (call)

Parameters

  • source string The radspec expression
  • call Object The call that determines the bindings for this evaluation
    • call.abi Array The ABI used to decode the transaction data
    • call.transaction Object The transaction to decode for this evaluation
      • call.transaction.to string The destination address for this transaction
      • call.transaction.data string The transaction data
  • options Object? An options object (optional, default {})
    • options.ethNode string? The URL to an Ethereum node

Examples

import radspec from 'radspec'

const expression = 'Will multiply `a` by 7 and return `a * 7`.'
const call = {
  abi: [{
    name: 'multiply',
    constant: false,
    type: 'function',
    inputs: [{
      name: 'a',
      type: 'uint256'
    }],
    outputs: [{
      name: 'd',
      type: 'uint256'
    }]
  }],
  transaction: {
    to: '0x8521742d3f456bd237e312d6e30724960f72517a',
    data: '0xc6888fa1000000000000000000000000000000000000000000000000000000000000007a'
  }
}

radspec.evaluate(expression, call)
  .then(console.log) // => "Will multiply 122 by 7 and return 854."

Returns Promise<string> The result of the evaluation