I cant figure out why calling a function from web app fails while calling from Polygonscan works...
Does anyone know why?
I am trying to call the function with the same args and condition yet calling from my test front end app fails. Without reasons for the failure.
Contract is here
The Contract Address 0x1d933e3d67a9ed692b027154bb988a93eea7ddc6 page allows users to view the source code, transactions, balances, and analytics for the contract address. Users can also interact and make transactions to the contract directly on...
when I call the function from the link above it works.
The function that doesn't work is below.
function release(bytes32 _proofId) external virtual proofExists(_proofId) {
ModInfoVesting storage modVestingInfo = modInfoVesting[_proofId];
require(
modVestingInfo.modAddress == msg.sender,
"msg.sender must be modAddress"
);
require(
block.timestamp > modVestingInfo.jobEndTime,
"now must be > jobEndTime"
);
require(
modVestingInfo.completed == false,
"release: you already completed"
);
uint256 releasable = releaseAmount(_proofId);
modVestingInfo.released += releasable;
if (modVestingInfo.amount == modVestingInfo.released) {
modVestingInfo.completed = true;
}
depositedToken.transfer(msg.sender, releasable);
emit Released(_proofId, msg.sender);
}
I read this post and changed from safeTransfer
to just transfer
but no luck...
I have created a simple ERC20 fixed supply token Crowdsale by extending the latest Openzeppelin Crowdsale.sol. Everything works fine… the only problem is, I struggled majorly with a vague error when buying tokens. After much debugging, I narrowed down my mysterious error to one line in the Crowdsale.sol file, that being the _token.safeTransfer line inside the _deliverTokens function. Replacing this with _token.transfer instead works. But this is obviously not ideal. I have entirely failed, howev…
its probably an error in your frontend code then, can you provide the relevant parts as well?
THank you for your reply!
here is my front end code
const Vesting = () => {
const { account, library } = useWeb3React<ethers.providers.Web3Provider>();
const [text, setText] = useState('');
const VestingContract = useMemo(() => {
if (!account) return null;
return new ethers.Contract(
VESTING_CONTRACT_ADDRESS,
VestingABI,
library?.getSigner(account)
) as VestingContract;
}, [account]);
const release = async () => {
if (!VestingContract || !text) return;
try {
const tx = await VestingContract.release(text, { gasLimit: 100000 });
await tx.wait();
console.log('tx : ', tx);
} catch (e) {
if (e instanceof Error) {
console.log('release error');
console.error(e);
console.log('e.message');
console.log(e.message);
}
}
};
return (
<div>
<h1>VESTING</h1>
<input
type="text"
value={text}
placeholder={'proofId'}
onChange={(e) => setText(e.target.value)}
/>
<button onClick={release}>Release</button>
</div>
);
};
export default Vesting;
You will find the entire code below.
Thanks for your help!
tbh I cant see the problem either
Interestingly, this transaction failed, while this transaction was successful, although both transactions came from the same address with the same params and there were no other state modifying transactions inbetween.
Thanks for checking.
Yeah... That is weird right?
So I cannot find any possible reasons
Weird? thing is that only successful transfers are recorded in transfer history.
New (NEW) Token Tracker on PolygonScan shows the price of the Token $0.00, total supply 50,000, number of holders 7 and updated information of the token. The token tracker page also shows the analytics and historical data.
You will see the method column "Release" so I assume something is wrong with the contract calling this Token contract?