Skip to content

Commit

Permalink
set gasLimit in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Nov 7, 2024
1 parent edca64c commit bddf609
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions examples/nft/contracts/Universal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract Universal is
SystemContract(0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9);
uint256 private _nextTokenId;
bool public isUniversal = true;
uint256 public gasLimit = 700000;
uint256 public gasLimit;

error TransferFailed();
error Unauthorized();
Expand All @@ -44,11 +44,13 @@ contract Universal is
address payable gatewayAddress,
address owner,
string memory name,
string memory symbol
string memory symbol,
uint256 gas
) ERC721(name, symbol) Ownable(owner) {
if (gatewayAddress == address(0) || owner == address(0))
revert InvalidAddress();
gateway = GatewayZEVM(gatewayAddress);
gasLimit = gas;
}

function setCounterparty(
Expand Down Expand Up @@ -130,7 +132,7 @@ contract Universal is
_setTokenURI(tokenId, uri);
} else {
(, uint256 gasFee) = IZRC20(destination).withdrawGasFeeWithGasLimit(
700000
gasLimit
);

SwapHelperLib.swapExactTokensForTokens(
Expand All @@ -146,7 +148,7 @@ contract Universal is
counterparty[destination],
destination,
abi.encode(tokenId, sender, uri),
CallOptions(700000, false),
CallOptions(gasLimit, false),
RevertOptions(address(0), false, address(0), "", 0)
);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/nft/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ GATEWAY_ETHEREUM=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain==
GATEWAY_BNB=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain=="bnb") | .address' localnet.json)
SENDER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

CONTRACT_ZETACHAIN=$(npx hardhat deploy --network localhost --json | jq -r '.contractAddress')
CONTRACT_ZETACHAIN=$(npx hardhat deploy --network localhost --json --gas-limit 1000000 | jq -r '.contractAddress')
echo -e "\n🚀 Deployed NFT contract on ZetaChain: $CONTRACT_ZETACHAIN"

CONTRACT_ETHEREUM=$(npx hardhat deploy --name Connected --json --network localhost --gateway "$GATEWAY_ETHEREUM" | jq -r '.contractAddress')
Expand Down
4 changes: 3 additions & 1 deletion examples/nft/tasks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
args.gateway,
signer.address,
args.nftName,
args.nftSymbol
args.nftSymbol,
...(args.gasLimit ? [args.gasLimit] : [])
);
await contract.deployed();

Expand All @@ -41,6 +42,7 @@ task("deploy", "Deploy the NFT contract", main)
.addOptionalParam("nftName", "NFT name", "Universal NFT")
.addOptionalParam("nftSymbol", "NFT symbol", "UNFT")
.addOptionalParam("name", "The contract name to deploy", "Universal")
.addOptionalParam("gasLimit", "Gas limit for the transaction")
.addOptionalParam(
"gateway",
"Gateway address (default: ZetaChain Gateway)",
Expand Down

0 comments on commit bddf609

Please sign in to comment.