Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/play3rzer0/callcalculator

A contract interaction example
https://github.com/play3rzer0/callcalculator

blockchain contract-interaction inheritance smartcontracts solidity web3

Last synced: about 4 hours ago
JSON representation

A contract interaction example

Awesome Lists containing this project

README

        

# CallCalculator

A contract interaction example.

This consists of two smart contracts:
1- Calculator.sol
2- Caller.sol

The calculator contract contains the main functions. The caller contract will call a function from the calculator contract to process data.

The data are passed as arguments to a parameter in the function on the calculator contract.

The caller will pass these parameters to the calculator:
function x(uint a, uint b) public view returns(uint) { .. }

The calculator upon invocation, will take the parameters as arguments and run the function:
function add(uint x, uint y) public pure returns(uint) { .. }

Since the data is not being stored onchain, to change the state, there is no gas cost. The function called is a "pure returns" type.

Updated(7/16/24):
Added an interface to the contract for function abstraction - CalculatorInterface.sol