Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carlosalegreur/interactioncontrol-smartcontract
InteractionControl combines different smart contracts to grant total control of your functions if desired. From who calls them to in which order and even with which inputs' values.
https://github.com/carlosalegreur/interactioncontrol-smartcontract
blockchain evm hardhat openzeppelin-solidity smart-contract solidity trustless web3
Last synced: 10 days ago
JSON representation
InteractionControl combines different smart contracts to grant total control of your functions if desired. From who calls them to in which order and even with which inputs' values.
- Host: GitHub
- URL: https://github.com/carlosalegreur/interactioncontrol-smartcontract
- Owner: CarlosAlegreUr
- License: mit
- Created: 2023-06-03T17:53:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-04T17:10:28.000Z (over 1 year ago)
- Last Synced: 2025-01-22T08:38:54.662Z (10 days ago)
- Topics: blockchain, evm, hardhat, openzeppelin-solidity, smart-contract, solidity, trustless, web3
- Language: Solidity
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# InteractionControl Contract
# Combines different smart contracts to grant total control of your functions if desired. From who calls them to in which order and even with which inputs' values.
## π½Testing and implementation example repo => [(click)](https://github.com/CarlosAlegreUr/InteractionControl-SmartContract-Testing) π½
## π½NPM repo => [(click)](https://www.npmjs.com/package/interaction-control-contract) π½
If further elaboration or development please mention me in your work.
π https://github.com/CarlosAlegreUr π
## π€ General usecase explanation π€
InteractionControl can be used to have total control of your functions if desired.
From who calls them to in which order and even with which inputs' values.
## β¨ How to use β¨
1. Make your contract inherit InteractionControl and add the isAllowedInteraction()
modifier in the functions you desire to fully control.The isAllowedInteraction() has 3 parameters:
1.1 => function selector of the function where it's being applied:
bytes4(keccak256(bytes("funcSignatureAsString")))1.2 => msg.sender => to know who is calling.
1.3 => a unique identifier of the inputs and it's values:
keccak256(abi.encode(\_newNumber))Btw it's essential you use abi.enconde() and not abi.encodePakced() because abi.encodePakced()
can give the same output to different inputs.2. Additionally you can override callAllowInputsFor() or and callAllowFuncCallsFor() if you please mixing this
InteractionControl with, for example, other useful ones like Ownable or AccessControl contracts from [OpenZeppelin](https://docs.openzeppelin.com/contracts/4.x/access-control).As InteractionControl inherits from [CallOrderControl.sol](https://github.com/CarlosAlegreUr/CallOrderControl-SmartContract-DesignPattern/blob/main/CallOrderControl.sol) and [InputControl.sol](https://github.com/CarlosAlegreUr/InputControl-SmartContract-DesignPattern/blob/main/InputControl.sol) you can use just their modifier directly in a function
if pleased.Check a simple implemented example at [UseCaseContract.sol](https://github.com/CarlosAlegreUr/InteractionControl-SmartContract-Testing/blob/main/contracts/UseCaseContract.sol).
## βοΈ DEPENDENCIES βοΈ
#### npm packages
- ### [InputControl](https://www.npmjs.com/package/input-control-contract)
- ### [CallOrderControl](https://www.npmjs.com/package/call-order-control-contract)
## π FUTURE IMPROVEMENTS π
- Improve and review (static analysis, audit...) code's tests.
- Test in testnet.
## π¨ Contact π¨
Carlos Alegre UrquizΓΊ - [email protected]
## β Buy me a CryptoCoffee β
Buy me a crypto coffe in ETH, MATIC or BNB βπ§β
(or tokens if you please :p )0x2365bf29236757bcfD141Fdb5C9318183716d866
## π License π
Distributed under the MIT License. See [LICENSE](https://github.com/CarlosAlegreUr/InteractionControl-SmartContract-DesignPattern/blob/main/LICENSE) in the repository for more information.