Create, Sign and send ethereum Transaction - ethereum

I am new in Ethereum. How can I sign an ethereum transaction. I am using Blockcypher php-client library. It works fine for Bitcoin. I have changed the network to eth.main and it works for ethereum too. But I can not sign ethereum transaction. The exception arises here in Blockcypher/Crypto/CoinSymbolNetworkMapping.php. . The exception arises. I have added the blue signed lines. But I don't know what are parametes in create function and what value should they have. By adding blue signed code It returns following exception:
Fatal error: Uncaught exception 'BlockCypher\Exception\BlockCypherSignatureException' with message '1 private keys do not correspond to any input. Please check private keys provided.' in C:\xampp\htdocs\bitcoin\api2\BlockCypher\php-client\lib\BlockCypher\Api\TXSkeleton.php on line 164. How can I sign a transaction using Blockcypher API for my website?

Related

ERC20: swapExactTokensForETH function showing error in Pancakeswap

I deployed a token on bscscan(testnet) and created an LP in pancake(testing). but when I try to swap tokens for BNB it is showing an error. I think this error is related to isExcludedFromFee bcoz when I make user isExcludedFromFee(true) then it's working fine. I am not able to find error.

How to show transaction on metamask when balance is 0

I'm using ethers.js and trying to call for a method on a contract using
myContract.myMethod(amount, {"value": ethers.utils.parseEther((price * amount).toFixed(2))});
the toFixed() is not important here (it's only because calculations with multiply and float gives answers like 12.000000002 and it's not passing the validation from the contract
I'm using metamask for the user to interact with the contract, the problem is when I have balance 0, and I'm trying to call for myMethod I get an error: 'insufficient funds for gas * price + value' but I want it to be that metamask will open and show the transaction, and it will be the one that will show the 'insufficient fund' error without getting an error in my code (this is mostly for user-friendly from the metamask UI). I haven't found any answer about it in the ethers.js documentation and I saw some sites that implement this logic somehow (for example https://opensea.io/).
Example how it opens in opensea site:
Is it possible to do this through ethers.js or any other way?
Thank you.

How can one obtain the message from state-reverting exception using ethereum clients, when self did not broadcast transaction?

Suppose an ethereum smart contract has external function "foo" whose logic has state-reverting exception require(1 == 0, 'error: you broke the simulation!');.
If ethereum-client A broadcasts transaction "txA" which is a function call on foo, how can ethereum-client B access the state-reverting message corresponding to "txA"?
edit: by "how can", I mean how can a developer practically enable ethereum-client B to access this data. i.e. Can you please point me in the direction of the correct (lower-level.. not webui) api/rpc call from a particular tool?
Clearly this is possible since block explorers provide such messages for failed transactions. I read through some of the source of etherscan, but their javascript is minimized and not easily readable.
Thanks in advance!
See this: https://ethereum.stackexchange.com/questions/39817/are-failed-transactions-included-in-the-blockchain
Failed transactions often are included in the chain.
What you sometimes see, if you're using e.g. MetaMask, is a popup saying "this transaction will fail" that happens before the transaction is sent to the chain. This is MetaMask trying to be helpful and prevent you wasting gas. But you can force send the transaction anyway, and you'll get a failed/reverted transaction posted on-chain (like this one for this Solidity source).
So to answer the original question, if TxA was posted on-chain, then client B will process it and get the revert message itself. If TxA was not posted on-chain, then there is no record of it.

Airdrop contract not working

I am trying to implement this Airdrop: https://github.com/odemio/airdropper/blob/master/Airdropper.sol
Initially, I started writing tests for our use-case, but the airdrop was not working.
function airdrop(address source, address[] dests, uint[] values) public onlyOwner {
// This simple validation will catch most mistakes without consuming
// too much gas.
require(dests.length == values.length);
for (uint256 i = 0; i < dests.length; i++) {
require(token.transferFrom(source, dests[i], values[i].mul(multiplier)));
}
}
Then I moved to Remix to goe through the whole airdrop process, including our Contract deployment, token minting and allowance.
In Remix debugger I found out that the issue is on the line
require(token.transferFrom(source, dests[i], values[i].mul(multiplier)));
I also tested the transferFrom function directly on our contract using the same values on Remix.
The error I get when trying to airdrop is:
transact to Airdrop.airdrop errored: VM error: revert.
revert The transaction has been reverted to the initial state.
Note: The constructor should be payable if you send value. Debug the transaction to get more information.
What could cause this issue and how can I debug this further? :)
Thanks and have a nice day!
The error could be for several reasons:
source doesn’t have enough tokens to cover all of the transfers.
One or more destination addresses are invalid.
The approve wasn’t done correctly (it’s the airdrop contract that needs to be approved, not the initiator of the transaction).
You can narrow it down by removing the require and see if any drops are successful (the way you have it coded, one failure will roll back the entire transaction).

VM Exception in solidity

I am using testrpc and truffle to test my smart contract before deploying it to the real network.
In my contract, each node has to register in the contract by calling the function register, after that he can send or receive messages to/from contract( the blockchain )
The problem is, when an address ( let say account 1 from testrpc accounts) call the functions (send or receive ) the transaction doesn't occur and this message appears
VM Exception while processing transaction: invalid JUMP at
But when I use another unregistered account to call this function, it works.
Although no messages have been sent or received but no exceptions..
Any idea how I can solve this.
Thanks
Unless your using an old version of solc to compile your solidity the chance of this being an optimization problem is almost none.
Now, what does this mean then, it can happen when for example you run a modifier and it doesn't work. or if you try to call a function you are not allowed to and it throws. For example, it happens a lot after an ICO finishes and you try to use a function that can't be used anymore due to a date constraint it returns an Invalid Jump
I can't see your code but I think you might have reversed your if condition in your modifier and now it returns true if the user is not registered.