When I call the write function to change the state of the contract, I use the Hedera SDK feature. Although the transaction receipt I receive is successful, the state of the contract does not change.
But I call on Hashcan.io again successfully and it actually works to change the state
Typescript Code
export async function createAuction(_auction: TAuctionCreation, walletInterface: WalletConnectWallet) {
const {
name,
description,
tokenId,
tokenAddress,
startingPrice,
minBidIncrement,
endingPrice,
endingAt,
receivers,
percentages
} = _auction;
if (!name) throw new Error('Name is required');
if (!description) throw new Error('Description is required');
if (!tokenAddress) throw new Error('Token address is required');
if (!tokenId) throw new Error('Token ID is required');
if (!startingPrice) throw new Error('Starting price is required');
if (!minBidIncrement) throw new Error('Minimum bid increment is required');
if (!endingPrice) throw new Error('Ending price is required');
if (!endingAt) throw new Error('Ending time is required');
try {
const transaction = await new ContractExecuteTransaction()
.setContractId(appConfig.constants.AUCY_CONTRACT_NFT_AUCTION_MANAGER_ID)
.setGas(MAX_GAS)
.setMaxAttempts(MAX_ATTEMPTS)
.setPayableAmount(new Hbar(100, HbarUnit.Tinybar))
.setFunction("createAuction", new ContractFunctionParameters()
.addString(name)
.addString(description)
.addAddress(ContractId.fromString(tokenAddress).toSolidityAddress())
.addInt256(tokenId.toString())
.addInt256(startingPrice.toString())
.addInt256(minBidIncrement.toString())
.addInt256(endingPrice.toString())
.addInt256(endingAt.toString())
.addAddressArray(receivers!)
.addInt16Array(percentages!)
)
// .freezeWithSigner(walletInterface.getSigner())
.freezeWith(client);
// const sign = await transaction.signWithSigner(walletInterface.getSigner());
// const txResponse = await sign.executeWithSigner(walletInterface.getSigner());
const txResponse = await transaction.execute(client);
console.log('txResponse', txResponse);
const receipt = await txResponse.getReceipt(client);
console.log('receipt', receipt);
return null;
} catch (error: any) {
console.error('Error creating auction', error);
throw new Error(error);
}
}
Solidity Function
function createAuction(string _name, string _description, address _tokenAddress, uint256 _tokenId, address _topicId, uint256 _startingPrice, uint256 _minBidIncrement, uint256 _endingPrice, uint256 _endingAt, address[] _receivers, uint16[] _percentages) returns (address)
I need everyone’s help, please give me a specific solution.