Bitsave solves it's problems with zeta chain using
- Interoperability of zetachain
- Cross chain saving features (1 contract, several chains supported)
- Safety with savings - cross chain swap. Converts savings to stable coin with the cross chain swap.
- Security With the minimal surface for attacks, savings are kept protected since they mostly are staying at a spot
- bitsaveAddress =>
0x6e299956270c355aAe829c2aaB435b2e81E5B5f6 - paymentTokenAddress =>
0x91d18e54DAf4F677cB28167158d6dd21F6aB3921 - parsedJoiningFee =>
parseUnits("100")
All interaction with the contract passes through the onCrossChainCall method.
After gaining the Contract object using whatever tool e.g. ethersjs,
You can name the Contract object as Bitsave, format example with ethersjs.
new ethers.Contract(
bitsaveAddress,
BitsaveABI,
signer // from the user's wallet
)You also create the Payment Token Contract object, can name as PaymentToken.
You also create the User Child Contract object, can name as UserChildContract.
All ABIs have been provided already, sources include
- BitsaveABI =>
hardhat_contract/artifacts/contracts/Bitsave.sol/Bitsave.json - UserChildContractABI =>
hardhat_contract/artifacts/contracts/userContract.bitsave.sol/UserContract.json - PaymentContractABI =>
hardhat_contract/artifacts/@zetachain/protocol-contracts/contracts/zevm/interfaces/IZRC20.sol/IZRC20.json
Each integration proceeds as follows:
- Approve joining fee:
PaymentToken.approve(bitsaveAddress, parsedJoiningFee)
- Call onCrossChainCall on Bitsave
Bitsave.onCrossChainCall(...arguments) - Pass the following arguments
- paymentTokenAddress
- parsedJoiningFee
- joinParameters(): (This function has been provided already) encodeParams("JON", 0, 0, 0, false) // this is data returned from it
- You can always retrieve the user's child address from
userChildContractAddress = Bitsave.getUserChildContractAddress() - From this child address, the userChildContract can be created using same approach for the Bitsave Object
- Approve saving amount Implementation in 'Join Bitsave'
- Call onCrossChain on Bitsave
- Pass the following arguments
- paymentTokenAddress
- parsed form of savingsAmount eg:
parseUnits(savingsAmount.toString()) - getSavingsParams(...arguments): (function provided already)
- arguments are:
- nameOfSaving,
- endTime: timestamp / 1000 // remove decimal,
- startTime: type of endTime
- penaltyPercentage: penaltyPercentage eg 1 or 2...
- isSavingInSafeMode: boolean
- You can always retrieve a particular savings data from
UserChildContract.getSavings(nameOfSaving)
- Approve saving amount Implementation in 'Join Bitsave'
- Call onCrossChain on Bitsave
- Pass the following arguments
- paymentTokenAddress
- parsed form of savingsAmount eg:
parseUnits(savingsAmount.toString()) - getSavingsParams(...arguments): (function provided already)
- arguments are:
- nameOfSaving,
- Call onCrossChainCall on Bitsave
- Pass the following arguments
- paymentTokenAddress
- 0
- getWithdrawParams(...arguments): (function provided already)
- arguments are:
- nameOfSaving
-
UserChildContract.getSavingsNames()
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.jshttps://xpan.notion.site/Zetachain-hackathon-progress-9c006cb9268c442fbcc8c0e8bca69747