17.4 Functions

MBADDRESS(address, headers, code)

Retrieve the details of a blockchain address.

Parameters

  • address Ethereum address or label.
  • headers (Optional) Include column headers. TRUE/FALSE, defaults to TRUE.
  • code (Optional) Include the smart contract bytecode deployed at the address, if any. TRUE/FALSE, defaults to FALSE.

Return

Address details.

Example

=MBADDRESS("0xe9f2E2B0105B683b436Fd0d7A2895BE25c310Af7", "", false) in the cell. The structure of the return value is as follows:

label address balance chain isContract modules contracts
privatefaucet 0xe9f2E2B0105B683b436Fd0d7A2895BE25c310Af7 2E+18 ethereum TRUE multibaasfaucet 1.0

MBBLOCK(numberOrHash, headers, txHashes)

Retrieve the details of a block.

Parameters

  • numberOrHash Block number or hash.
  • headers (Optional) Include column headers. TRUE/FALSE, defaults to TRUE.
  • txHashes (Optional) Include the transaction hashes. TRUE/FALSE, defaults to TRUE.

Return

Block details.

Exmaple

=MBBLOCK(12) in the cell. The structure of the return value is as follows:

blockchain hash difficulty gasLimit number timestamp receipt txHashes
ethereum 0x4ff2fbf3d751c1d7b4af45fb5ebeae4b92b87779ad9713415c7e1c96c7d66c3f 2 9883456 12 5/24/2020 0xbb5ffb2963ae9f743623ec04537705ea7c2c6388ffa0b3fff72c0e27e06f0a55 0x9e1d4dea734aa14130a1970c5f5b00f9d0ac401fdf52bb9ba027af9dfe509abc

MBCOMPOSE(address, contract, method, from, signer, value, ...args)

Compose an unsigned transaction to call a smart contract function.

Parameters

  • address Ethereum address or label.
  • contract Smart contract label, must be associated with the address.
  • method Smart contract function name.
  • from From address.
  • signer (Optional) Signer address. Defaults to the 'from' address.
  • value (Optional) Value for amount of ETH sent.
  • args (Optional) Arguments to pass to the function.

Return

An unsigned transaction, suitable for signing and submitting to the blockchain.

Example

=MBCOMPOSE("multibaasfaucet", "multibaasfaucet", "deposit", "0xA616eEd6aD7A0cF5d2388301a710c273ca955e05", "0xA616eEd6aD7A0cF5d2388301a710c273ca955e05", 100000000000000000) in the cell. The structure of the return value is as follows:

{"from":"0xA616eEd6aD7A0cF5d2388301a710c273ca955e05","to":"0x317570b8c43feCaDb8Ebaf765044Ad9626F4848e","value":"100000000000000000","gas":22774,"gasPrice":"20000000000","data":"0xd0e30db0","nonce":6,"hash":"0x72f0a63bc24503d1b71e93729c7787891633aa192dadb999f87b0f343a8ecbf4"}

MBCUSTOMQUERYTEMPLATE(numSelects, numFilters)

Create a template to be used with a custom MultiBaas Event Query.

Parameters

  • numberOfSelects (Optional) Number of 'select' groups to create. Default is 1.
  • numberOfFilters (Optional) Number of 'filter' groups to create. Default is 1.

Return

A two dimensional array that can be used as the starting point for a custom Event Query.

Example

=MBCUSTOMQUERYTEMPLATE(2, 0) in the cell. The structure of the return value is as follows:

eventName alias index aggregator alias index aggregator rule operator value
LogDeposited(address,uint256) sender 0 amount 1

MBCUSTOMQUERY(events, groupBy, orderBy, limit, offset)

Retrieve the results of a custom MultiBaas Event Query. You can use MBCUSTOMQUERYTEMPLATE to generate a useful template.

Parameters

  • events Two dimensional array of event names, selectors and filters.
  • groupBy (Optional) Field to group by.
  • orderBy (Optional) Field to order by.
  • limit (Optional) Number of results to return.
  • offset (Optional) Offset from the 0th result to return.

Return

A two dimensional array with the results of the Event Query.

Example

Let's say the given B35:H36 consists of MBCUSTOMQUERYTEMPLATE example above.

=MBCUSTOMQUERY(B35:H36, "", "", 3, 0) in the cell. The structure of the return value is as follows:

amount sender
1000000000000000000000000000 0x89d048be68575f2b56a999ba24faacabd1b919fb
1000000000000000000 0xa616eed6ad7a0cf5d2388301a710c273ca955e05
1000000000000000000 0xbac1cd4051c378bf900087ccc445d7e7d02ad745

MBEVENTLIST(contract, filter)

Retrieve a detailed list of a smart contract's events.

Parameters

  • contract Smart contract label, must be associated with the address.
  • filter (Optional) Regular expression (regex) to filter function names on.

Return

Array of smart contract functions and their inputs and outputs.

Example

=MBEVENTLIST("multibaasfaucet") in the cell. The structure of the return value is as follows:

event description inputs
LogCurrentOperatorRevoked "2 inputs: owner address operatorRevoked address"
LogDeposited "2 inputs: sender address amount uint256"
LogOperatorCandidateAccepted "1 input: candidateAccepted address"
LogOperatorCandidateRequested "2 inputs: owner address candidate address"
LogOperatorCandidateRevoked "1 input: candidateRevoked address"
LogOwnerCandidateAccepted "1 input: candidateAccepted address"
LogOwnerCandidateRequested "2 inputs: owner address candidate address"
LogOwnerCandidateRevoked "1 input: candidateRevoked address"
LogPaused "1 input: owner address"
LogSent "2 inputs: receiver address amount uint256"
LogUnpaused "1 input: owner address"
LogWithdrew "2 inputs: owner address amount uint256"

MBEVENTS(address, limit, offset)

Retrieve blockchain events. Address must be associated with one or more contracts in MultiBaas.

Parameters

  • address Ethereum address or label.
  • limit (Optional) Number of results to return.
  • offset (Optional) Offset from the 0th result to return.

Return

A two dimensional array of events.

Example

=MBEVENTS("privatefaucet", 1, 2) in the cell. The structure of the return value is as follows:

triggeredAt eventName eventDef eventInput0 eventInput1 eventIndexInLog eventContractAddressLabel eventContractAddress eventContractName txFrom txData txHash txIndexInBlock txBlockHash txBlockNumber txContractAddressLabel txContractAddress txContractName fnName fnDef
6/19/2020 LogDeposited LogDeposited(address sender,uint256) amount 0xA616eEd6aD7A0cF5d2388301a710c273ca955e05 1000000000000000000 0 multibaasfaucet 0xe9f2E2B0105B683b436Fd0d7A2895BE25c310Af7 MultiBaasFaucet 0xA616eEd6aD7A0cF5d2388301a710c273ca955e05 0xd0e30db0 0x937f1d11da26d7350e66691bd1e8669961d3cb4727978fd6213265b504174fbf 0 0x611df11ac2d2e8a2da1e305817f1342bed60667c7d1a7292f6da09e7f4a1cc66 149 multibaasfaucet 0xe9f2E2B0105B683b436Fd0d7A2895BE25c310Af7 MultiBaasFaucet deposit deposit()

MBFUNCTIONLIST(contract, filter)

Retrieve a detailed list of a smart contract's functions.

Parameters

  • contract Smart contract label, must be associated with the address.
  • filter (Optional) Regular expression (regex) to filter function names on.

Return

Array of smart contract functions and their inputs and outputs.

Example

=MBFUNCTIONLIST("erc20interface") in the cell. The structure of the return value is as follows:

function description read/write inputs outputs
allowance read "2 inputs: tokenOwner address spender address" "1 output: remaining uint256"
approve write "2 inputs: spender address tokens uint256" "1 output: success bool"
balanceOf read "1 input: tokenOwner address" "1 output: balance uint256"
decimals read no inputs "1 output: uint8"
name read no inputs "1 output: string"
symbol read no inputs "1 output: string"
totalSupply read no inputs "1 output: uint256"
transfer write "2 inputs: to address tokens uint256"
transferFrom write "3 inputs: from address to address tokens uint256" "1 output: success bool"

MBGET(address, contract, method, ...args)

Retrieve the results of a smart contract function call.

Parameters

  • address Ethereum address or label.
  • contract Smart contract label, must be associated with the address.
  • method Smart contract function name.
  • args (Optional) Arguments to pass to the function.

Return

One or more values returned from the function.

Example

=MBGET("privatefaucet", "multibaasfaucet", "getOperator") in the cell. The structure of the return value is as follows:

0x005080F78567F8001115F1eee835DD0151BEA476

MBPOSTTEMPLATE(numberOfArgs)

Create a template to be used with calling a smart contract method (function) that will write to the blockchain.

Parameters

  • numberOfArgs (Optional) Number of arguments (parameters) to pass to the method (function). Default is 0.

Return

A two dimensional array that can be used as the starting point for calling a smart contract method.

Example

=MBPOSTTEMPLATE(1) in the cell. The structure of the return value is as follows:

address contract method from signer input0 txHash (output)

MBTX(hash, headers)

Retrieve the details of a blockchain transaction.

Parameters

  • hash Transaction hash.
  • headers (Optional) Include column headers. TRUE/FALSE, defaults to TRUE.

Return

Transaction details.

Example

=MBTX("0xfe9e4b800d14c36f2e8c26ab44ffcfcbf55ac71d6f0d5f2ac95b3d63c7f71569") in the cell. The structure of the return value is as follows:

isPending nonce gasPrice gas to value input v r s hash
FALSE 42 20000000000 22774 0xe9f2e2b0105b683b436fd0d7a2895be25c310af7 1E+18 0xd0e30db0 0xf0742a46 0xf7d63ad5985bfcc8f1764198a32d7e1800e852b2408068b0904187c3e3b3c4dc 0x290fae6d05ef9007ce21f8144629edbd7ebf23a1205a3b4a74a3746c6737132c 0xfe9e4b800d14c36f2e8c26ab44ffcfcbf55ac71d6f0d5f2ac95b3d63c7f71569

MBQUERY(query, limit, offset)

Retrieve the results of a MultiBaas Event Query.

Parameters

  • query Event Query name to return results from.
  • limit (Optional) Number of results to return.
  • offset (Optional) Offset from the 0th result to return.

Return

A two dimensional array with the results of the Event Query.

Example

=MBQUERY("Faucet", 2, 1) in the cell. The structure of the return value is as follows:

amount sender
1000000000000000000 0xa616eed6ad7a0cf5d2388301a710c273ca955e05
1000000000000000000 0xbac1cd4051c378bf900087ccc445d7e7d02ad745

Post to the blockchain

Compose, sign, and submit a transaction to the blockchain. An enterprise wallet (Hardware Security Module or HSM) must be configured in the MultiBaas deployment. An HSM address will be used to sign the transaction (web3 browsers such as MetaMask will not work to sign transactions in Google Sheet).

  • For example, MBPOSTTEMPLATE might output:
address contract method from signer input0 txHash (output)
  • Enter parameters under each column name as follows. Multiple rows can be entered for multiple transactions.
address contract method from signer input0 txHash (output)
oootoken mltitoken mint 0xF9450D254A66ab06b30Cfa9c6e7AE1B7598c7172 0xF9450D254A66ab06b30Cfa9c6e7AE1B7598c7172 100
  • Drag and select all of the parameters entered, across one or more rows. Go to Add-ons > MultiBaas for Google Sheets > Post to the blockchain
  • The txHash (output) will be filled in as each transaction is submitted to the blockchain:
address contract method from signer input0 txHash (output)
oootoken mltitoken mint 0xF9450D254A66ab06b30Cfa9c6e7AE1B7598c7172 0xF9450D254A66ab06b30Cfa9c6e7AE1B7598c7172 100 0xadc05ba56c5670fe56180e610e87667909983f39aebb33af7c602272e9c0d5fc

Refresh current cell

This is a convenience function to refresh the current cell's custom function.

  • Select a cell which has a custom function. For example, =MBQUERY("Faucet", 2, 1) might be in the cell.
  • Go to Add-ons > MultiBaas for Google Sheets > Refresh current cell