nft-tutorial
nft-tutorial copied to clipboard
part 4 / withdrawal task is missing in hardhat
During Step 4 we add the support of withdrawPayments()
to our smart contract however if you want to call that method you need a new hardhat task which is not proposed in the guide.
I suggest something like:
task("withdraw", "*** Transfer the ETH hold by the SC to the account")
.setAction(async function (taskArguments, hre) {
const account = getAccount();
const contract = await getContract("NFT", hre);
const transactionResponse = await contract.withdrawPayments(account.address,
{
gasLimit: 500_000,
});
console.log(`Transaction Hash: ${transactionResponse.hash}`);
});
This way calling npx hardhat withdraw
should withdraw the SC ETH to the account specified with the ACCOUNT_PRIVATE_KEY
env variable
This is very helpful thank you. Note you need const { getAccount } = require("./helpers");
at the top of the file also.
Issue https://github.com/ProjectOpenSea/nft-tutorial/issues/4 remains however: When I tried the above task on a Rinkeby contract which had 0.03ETH in it, the withdraw transaction completed successfully but the transaction value on etherscan was 0.00 and nothing was added to my wallet.
Any ideas??
@cronoklee I'm at the same place you are.
...Do we need to specify an amount in the withdrawPayments
action?
OZ docs say it's just all funds, but they also say withdrawPayments
is deprecated in favor of withdrawPaymentsWithGas
.
Adding a call to _asyncTransfer after _safeMint call in the contract seems to solve the issue tho the contract behaves a little differently now. See the pull request for details https://github.com/ProjectOpenSea/nft-tutorial/pull/1
I saw that, and thanks! That meant that the contract address has funds, but my withdraw
still doesn't seem to be able to move those funds (although it publishes a transaction).