mirror of
https://github.com/luxfhe/example-poker.git
synced 2026-10-30 18:13:22 +00:00
- @luxfhe/wasm: ^0.2.0 - @luxfhe/kms: ^0.2.0 - @luxfhe/relayer-sdk: ^0.6.0 - @luxfhe/mock-contracts: ^0.6.0 - Remove deprecated Zama dependencies
52 lines
2.0 KiB
TypeScript
52 lines
2.0 KiB
TypeScript
import { DeployFunction } from "hardhat-deploy/types";
|
|
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
|
|
|
const CONTRACT_NAME = "FHEKuhnPoker";
|
|
|
|
/**
|
|
* Deploys a contract named "FheKuhnPoker" using the deployer account and
|
|
* constructor arguments set to the deployer address
|
|
*
|
|
* @param hre HardhatRuntimeEnvironment object.
|
|
*/
|
|
const deployFheKuhnPoker: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|
/*
|
|
On localhost, the deployer account is the one that comes with Hardhat, which is already funded.
|
|
|
|
When deploying to live networks (e.g `yarn deploy --network goerli`), the deployer account
|
|
should have sufficient balance to pay for the gas fees for contract creation.
|
|
|
|
You can generate a random account with `yarn generate` which will fill DEPLOYER_PRIVATE_KEY
|
|
with a random private key in the .env file (then used on hardhat.config.ts)
|
|
You can run the `yarn account` command to check your balance in every network.
|
|
*/
|
|
const { deployer } = await hre.getNamedAccounts();
|
|
const { deploy } = hre.deployments;
|
|
|
|
// Fund the account before deploying.
|
|
if (hre.network.name === "localluxfhe") {
|
|
const signers = await hre.ethers.getSigners();
|
|
|
|
if ((await hre.ethers.provider.getBalance(signers[0].address)).toString() === "0") {
|
|
await hre.luxfhe.getFunds(signers[0].address);
|
|
console.log("Received tokens from the local faucet. Ready to deploy...");
|
|
}
|
|
}
|
|
|
|
await deploy(CONTRACT_NAME, {
|
|
from: deployer,
|
|
// Contract constructor arguments
|
|
args: [],
|
|
log: true,
|
|
// autoMine: can be passed to the deploy function to make the deployment process faster on local networks by
|
|
// automatically mining the contract deployment transaction. There is no effect on live networks.
|
|
autoMine: true,
|
|
});
|
|
};
|
|
|
|
export default deployFheKuhnPoker;
|
|
|
|
// Tags are useful if you have multiple deploy files and only want to run one of them.
|
|
// e.g. yarn deploy --tags FheKuhnPoker
|
|
deployFheKuhnPoker.tags = [CONTRACT_NAME];
|