The contract instance API

Each contract instance is different based on the source Solidity contract, and the API is created dynamically. Here are the various the APIs of a contract instance:

  • allEvents: This is a function of a contract instance that takes a callback that is invoked whenever an event is fired by the contract matching the event signature under the current network ID in the contract artifacts object. You can also use event name-specific functions to catch specific events instead of all of them. In the preceding contract, to catch ping events, you can use SampleContract_Instance.ping(function(e, r){}).
  • send: This function is used to send ether to the contract. It takes two arguments; that is, the first argument is the amount ...

Get Building Blockchain Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.