0

As an exercise to learn Solidity and Nextjs, I started developing a presale smartcontract. It has gotten rather large but I am proud of how far I have come in two months. The contract mints a token, and users can buy this token in a presale. This functionality is implemented by the getAllocation function.

I know it works because I have tried to run it on Remix IDE successfully.

I implemented a frontend with Next.js and I am using web3Modal to connect to users wallet. Connecting to Metamask or other wallets works fine, but when I try to purchase a token, there is a problem: the right amount of ether is passed and the transaction is recorded on blockchain, but user receives no custom tokens in exchange. The expected behaviour is that a user should receive an equivalent amount of presale tokens for ether sent.

Code gist for the smartcontract and the component that creates a connection (addresses used are standard issue from hardhat). https://gist.github.com/dragonskyside/85fe2ca082e1d0ac8f075b426a73585f Kindly show me what I'm doing wrong here, and anywhere else in the code.

1
  • Good work, can't see obvious issue just skimming gist. If still struggling add a hash of the failure, let us see what call data is being passed around.
    – Maka
    Commented May 29 at 12:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.