You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to send BEP-20 tokens from one address to another. I am getting the following error while attempting to sign the transaction with Privatekey. "Uncaught InvalidArgumentException: The input type didn't support" at this line of code $signedTransaction = $ethereumTx->sign($privateKey);
// Replace with the actual contract address and ABI
$contractAddress = '0x55d398326f99059fF775485246999027B3197955';
$recipientAddress='0x7Affe1A120843E41b271E577900F0B5c43c2C2d9';
$tokenDecimals = 18; // Replace with the actual token's decimal places
$amount = 1; // Replace with the actual amount you want to transfer
I am trying to send BEP-20 tokens from one address to another. I am getting the following error while attempting to sign the transaction with Privatekey. "Uncaught InvalidArgumentException: The input type didn't support" at this line of code
$signedTransaction = $ethereumTx->sign($privateKey);
Here is the full code :
`
require 'web3.php/vendor/autoload.php';
require 'ethereum_tx/autoload.php';
use Web3\Web3;
use Web3\Contract;
use Web3\Utils;
use Web3p\EthereumTx\Transaction;
$web3 = new Web3('https://bsc-dataseed.binance.org/'); // Use the BSC node URL
// Replace with the actual contract address and ABI
$contractAddress = '0x55d398326f99059fF775485246999027B3197955';
$recipientAddress='0x7Affe1A120843E41b271E577900F0B5c43c2C2d9';
$tokenDecimals = 18; // Replace with the actual token's decimal places
$amount = 1; // Replace with the actual amount you want to transfer
$amountInBaseUnits = $amount * (10 ** $tokenDecimals);
$contractABI = "contract ABI";
// Set your wallet's private key
$privateKey = "myprivatekey";
$eth = $web3->eth;
// Create an instance of the contract using the ABI and address
$contract = new Contract($web3->provider, $contractABI, $contractAddress);
$transferFunctionCall = $contract->at($contractAddress)->getData(
'transfer', // Function name
$recipientAddress, // Parameter 1
$amountInBaseUnits // Parameter 2
);
// Fetch the nonce asynchronously
$web3->eth->getTransactionCount('0x02e6deD21C6c46CC4FFF2991988af13069C7c2A3', function ($err, $nonce) use ($web3, $contractAddress, $transferFunctionCall, $privateKey) {
if ($err !== null) {
echo "Error fetching nonce: " . $err->getMessage();
} else {
// Construct the transaction
$transaction = [
'from' => '0x02e6deD21C6c46CC4FFF2991988af13069C7c2A3',
'to' => $contractAddress,
'gas' => '0x' . dechex(100000), // Replace with appropriate gas value
'data' => $transferFunctionCall,
'nonce' => $nonce
];
$signedTransaction = $ethereumTx->sign($privateKey);
});
var_dump($transactionHash);
`
The text was updated successfully, but these errors were encountered: