LazyTower Solidity libraries.
This library has not been audited.
✔️ LazyTowerHashChain (Poseidon)
Install the @zk-kit/lazytower.sol
package with npm:
npm i @zk-kit/lazytower.sol --save
or yarn:
yarn add @zk-kit/lazytower.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "../LazyTowerHashChain.sol";
contract LazyTowerHashChainTest {
using LazyTowerHashChain for LazyTowerHashChainData;
event Add(uint256 item);
// map for multiple test cases
mapping(bytes32 => LazyTowerHashChainData) public towers;
function add(bytes32 _towerId, uint256 _item) external {
towers[_towerId].add(_item);
emit Add(_item);
}
function getDataForProving(bytes32 _towerId) external view returns (uint256, uint256[] memory, uint256) {
return towers[_towerId].getDataForProving();
}
}
import { Contract } from "ethers"
import { task, types } from "hardhat/config"
task("deploy:lazytower-test", "Deploy a LazyTowerHashChainTest contract")
.addOptionalParam<boolean>("logs", "Print the logs", true, types.boolean)
.setAction(async ({ logs }, { ethers }): Promise<Contract> => {
const PoseidonT3Factory = await ethers.getContractFactory("PoseidonT3")
const PoseidonT3 = await PoseidonT3Factory.deploy()
if (logs) {
console.info(`PoseidonT3 library has been deployed to: ${PoseidonT3.address}`)
}
const LazyTowerLibFactory = await ethers.getContractFactory("LazyTowerHashChain", {
libraries: {
PoseidonT3: PoseidonT3.address
}
})
const lazyTowerLib = await LazyTowerLibFactory.deploy()
await lazyTowerLib.deployed()
if (logs) {
console.info(`LazyTowerHashChain library has been deployed to: ${lazyTowerLib.address}`)
}
const ContractFactory = await ethers.getContractFactory("LazyTowerHashChainTest", {
libraries: {
LazyTowerHashChain: lazyTowerLib.address
}
})
const contract = await ContractFactory.deploy()
await contract.deployed()
if (logs) {
console.info(`Test contract has been deployed to: ${contract.address}`)
}
return contract
})
- e-mail : lcamel@gmail.com
- github : @LCamel
- website : https://www.facebook.com/LCamel