Converter Token Manager V3: Lock tokens mechanic
Recommended using WSLv2/Linux/MacOS with LTS Node >= 18 & NPM >= 10 version
Table of Contents
- Install dependencies
npm install
- Install dependencies
npx hardhat compile
The Token.sol
file with a sample token contract is only needed to run the tests (Not for audit).
- Run Tests
npx hardhat test
The Token.sol
file with a sample token contract is only needed to run the tests(Not for audit).
- Run Tests
npx hardhat coverage
A contract is needed to convert tokens as part of the bridge between blockchains.
The contract will receive data about the transfer between different blockchains, including the signature that is generated on the backend, thereby verifying the transaction.
A detailed description of the contract's capabilities and mechanics of its use can be found in the document.
- Converter Contract Admin (Owner of contract) - can setup contract
- User - can use conversion tokens functions
- Converter Authorizer - account using for internal validation each conversion via signature in the contract
As part of the functionality, the contract should be able to transfer and lock of the users tokens for later issuance on another blockchain.
The converter contract should also be able to issue a validated number of tokens when using a specific role in the token.
The contract validates the minimum and maximum number of tokens within each conversion transaction.
The TokenConversionManager
contract manages token conversions between Ethereum and non-Ethereum networks with signature verification. Signature is received from backend service and is used in order to prevent replay attacks. Key functionalities include updating authorizer address (backend service address actually) and configurations, and executing conversions in and out.
-
constructor
- Description: Initializes the contract with token address, and sets the conversion authorizer to the deployer.
-
conversionOut
- Parameters:
uint256 amount, bytes32 conversionId, uint8 v, bytes32 r, bytes32 s
- Description: Converts tokens from Ethereum to non Ethereum network. The tokens which needs to be convereted will transfer to convtract for lock on the Ethereum network. The conversion authorizer needs to provide the signature to call this function.
- Parameters:
-
conversionIn
- Parameters:
address to, uint256 amount, bytes32 conversionId, uint8 v, bytes32 r, bytes32 s
- Description: Converts tokens in (transferring them) after verifying the signature and preventing replay attacks.
- Parameters:
-
updateAuthorizer
- Parameters:
address newAuthorizer
- Description: Updates the conversion authorizer address. Only callable by the contract owner.
- Parameters:
-
updateConfigurations
- Parameters:
uint256 perTxnMinAmount, uint256 perTxnMaxAmount
- Description: Updates the conversion configuration limits. Only callable by the contract owner.
- Parameters:
-
getconversionAuthorizer
- Returns:
address
- Description: Returns the current conversion authorizer address.
- Returns:
-
getConversionConfigurations
- Returns:
(uint256, uint256, uint256)
- Description: Returns the current conversion configuration limits.
- Returns:
-
_conversionAuthorizer
- Type:
address
- Description: Stores the address of the entity authorized to approve conversions.
- Type:
-
_usedSignatures
- Type:
mapping (bytes32 => bool)
- Description: Tracks used conversion signatures to prevent replay attacks.
- Type:
-
_perTxnMinAmount, _perTxnMaxAmount
- Type:
uint256
- Description: Configurations for minimum and maximum transaction amounts.
- Type: