Brigade is a cross-chain bridge monitor, connecting to live or private chains. It analyzes cross-chain transactions to enforce security policies on them, effectively detecting security issues and exploits.
To setup endpoints use the .env.sample to setup endpoints. Add for each endpoint the corresponding environment variable or the direct API key.
Where do I get the Filter from? Take a look at the RPC API provided by the Blockchain. There will be a description on how to build the JSON RPC call.
- String
- Number
- SignedNumber
- Bool
- Array
- Map
Variables are defined through the properties, environment events or through certain keywords like the assign function Variables are marked with '$' and can contain arbitrary data types.
Variables are always local to the event where they are created. However, by adding the variables either to the keystore or the map allows to make variables persistent
Warning: Make sure to remove the values from the persistent storage after they are used. Otherwise the storage get's bloated.
The special variables $keystore and $map are global and can be used to persistently store variables throughout events or chains.
Preset variables include:
$chain_name_block_number, e.g.,$ethereum_block_numberholds the block number of the current event$config_file_prefix_contract, e.g.,$eth2_contractholds the contract address for each config file. Hint: name config files withprefix_config.json
Here is a list of all supported functions. Note that not every data type can be used with every function.
When using arrays, every operation itself is a for each operation.
However, by using the at() function only one index is used.
Contains()array.contains(value) returns true || falsestring.contains(substring) returns true || false- Return whether a collection contains an item
- Not applciable in maps. Use get() instead!
At()array.at(index) returns arr[index] || Err- Return the value at a given index
As()T.as(ConversionTarget) returns ConvertedValue(T)- Convert a value into the specified type
Slice()array.slice(start, end) returns array[start..end]string.slice(start, end) returns substring- Return a slice of a collection
Push()- T = array | string
T.push(value) returns new_T || false- push a new item on a collection
Pop()- T = array | string
T.pop() returns last_item- return the last item of a collection
Keccak256(WIP)Insert()map.insert(key, value) returns true || false- Insert a new value with a key into a map
Remove()map.remove(key) returns true || false- Removes a specified key from a Map
Get()map.get(key) returns value- Get the value at the key.
Assignassign(variable_name, value)- Create a new variable with a name and a value
- 'Custom Functions'
call(connection, functionname, [args])- Calls the RPC method in the directory ./functions/connection/rpc.json with the arguments provided The folder functions/connection/ needs a connection.json that specifies the "endpoint" as a JSON argument to the http endpoint of the blockchain. The function itself specifies the RPC method to call and the params for the RPC. Returns a map that can be queried with the get method
Require()require(condition, statement)- Execute a statement under a condition or return false if the condition fails
- more complex conditions have to be wrapped in parenthesis
Note: Sometimes functions return strings but the context needs the result to be a boolean. Therefore, string can be compared with a boolean true to evaluate to true:
$str.push(a) && true
The following types can be converted from and to:
- u256
- i256
- string
- hex
In some cases it is necessary to have environment variables which are stored before execution.
Therefore, running the Tool with the -p <file_path> flag can take predefined patterns and deploy the variables at startup.
Note: The patterns are not updated "during" the execution
The file provided is a json file with a single array as root element, containing all comma separated strings for variables.
E.g.
["$keystore.push(0xaabb223344aaccddee)", "$map.insert(key, value)"]