Smart Contract throwing reversion when called from frontend but fine when called from remix - solidity

I am facing an odd case where I am calling a view method in a smart contract with the correct address and ABI but am getting a reversion from the contract itself when it's being called through a library such as web3 from a frontend web application.
However, when trying on remix for example, with the same contract and method and parameters and address, the method is working.
Can anyone provide some insight into this?

Had to use .call({from: userAddress}) instead of just .call()

Related

It is possible to change BEP-20 smart contract code?

I have deployed a contract on the BEP-20 network and now I don't need mint and owner address transfer functionality.
So I want to remove these options from the "write contract" options list.
If it is possible if yes then what can I do?
Smart contract bytecode is immutable. Assuming that your contract is not a proxy but a regular contract - you cannot change the already deployed code.
After you've made the changes in your local code, you'll need to recompile it, and deploy to a new address.

web3py ABIFunctionNotFound

I'm new to web3 development, trying to signing transaction over web3py and got an exception ABIFunctionNotFound when I try to create transfer via contract.functions.transfer() function for USDC token on BSC network.
web3.exceptions.ABIFunctionNotFound: ("The function 'transfer' was not found in this contract's abi. ", 'Are you sure you provided the correct contract abi?')
Token ABI
[{"inputs":[{"internalType":"address","name":"logic","type":"address"},{"internalType":"address","name":"admin","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"changeAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
If there are no function transfer in this contact, how can I transfer USDC to another wallet?
As I guessed in the comment, you're passing the ABI of the proxy contract.
The solution is simple: Pass the ABI of the implementation contract (you can see it linked from the Proxy contract on BSCScan) but keep the proxy address.
This rule applies to all other proxy contracts if you encounter this issue another time. Always pass the proxy address and the implementation ABI.

bep20 contract deploymenent token not found

I created/fork a bep20 token, if finishes successfully & contract fully created.
But i cant see the token or anything related to the token in the contract. the only thing visible are the contract address, transaction hash. e.t.c. you can check the link below to verify my words.
https://bscscan.com/tx/0xc61a353504deca41bdfb46b199f91adedd2bbd19f5ddae29ba54122a71e68c3f
As the contract detail page says, you deployed the library Address - not the contract SafeMoon that you probably wanted to deploy.
Since you're deploying the contract using Remix, you need to select the correct contract in the Deploy tab.

how I get new contract

I want a solidity contract to compile and deploy in remix.ethereum
the contract code I used brings always errors!
Error message:
This contract may be abstract, not implement an abstract parent’s methods completely or not invoke an inherited contract’s constructor correctly.
I want to use a new contract to verify and publish my tokens.
can you help me pls with a new contract that works with a remix and verifying etherscan?
regards
Based on the error message, you are trying to deploy the ERC20Interface instead of the contract x.
The solution is simple in Remix: Chose the correct contract to deploy from the selectbox.

How to mint ERC20 token using web3.js library?

I have been working on ERC20 token development. My code is written using solidity and zeppelin frameworks.
So far I have used the test networks like Rinkeby, Ropsten to deploy and test all the ERC20 methods. Last night, I have to deploy the smart contract in the mainnet where 10000000 tokens had to be deployed but I deployed only 1000000 (missed a zero).
As it is deployed in the mainnet, mint is the only way to top up the initial amount instead of redeploying. Mint is achievable using remix by removing the internal keyword in the mint method. But it requires to redeploy the smart contract in order to use mint method, which customer would not agree to redo the same.
The only way I think is to use web3js API to achieve the same. But there are no content given in the web3js document to how to pragmatically mint (to top up the initial amount).
If any of you have faced a similar situation, please let me know how you tackled it.
Thanks,
Sriram
The mint using web3 would be just a call to the contract function just like from remix, nothing special. All you would have to do would be to call the function. But since this function internal you cannot call it directly not from remix, not from web3, not from any other library. To put it simply if you cannot call the function from remix you cannot do it from web3 either. Web3 offers nothing more than remix in terms access rights to the contract.