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'm trying to send the data but i got the following error. i managed to get an existing data from the blockchain, but sending gives out either "Please make sure you have put all function params and callback"
solidity function
function addInfo(
uint256 uniqueKey,
string memory _userInfo
) public {
uniqueKeyIndexes[uniqueKey].push(uniqueKey);
userInfo[uniqueKey] = _userInfo;
emit infoAdded(uniqueKey);
}
php
$web3 = new Web3(getenv('NODE_PATH') . ':8545');
$abiAddress = 'contract.json';
$contractAbi = json_decode(file_get_contents($abiAddress));
$contract = new Contract($web3->getProvider(), $contractAbi->abi);
$senderAddress = 'sender_add';
$contractAddress = 'contact_add';
$functionName = 'addInfo';
$data = [123, $data_bc];
$privateKey = '123priv';
$contract->at($contractAddress)->send($functionName, $data, function ($err, $transactionHash) use ($web3, $privateKey) {
if ($err !== null) {
echo 'Error: ' . $err->getMessage() . PHP_EOL;
} else {
// Sign the transaction
$signedTransaction = $web3->eth->accounts->signTransaction([
'data' => $transactionHash,
], $privateKey);
// Send the signed transaction to the network
$web3->eth->sendRawTransaction($signedTransaction, function ($err, $transactionHash) {
if ($err !== null) {
"echo 'Error sending transacton: ' . $err->getMessage() . PHP_EOL;
} else {
echo 'Transaction Hash: ' . Utils::toString($transactionHash) . PHP_EOL;
}
});
}
}); //FIXME: error here
i'm not exactly sure what i've done wrong. i've tried following #238 and i got "Wrong type of eth_sendTransaction method argument 0"
$data_new = json_decode($data_bc, true);
$data_new['from'] = $senderAddress;
$data_new['privateKey'] = $privateKey;
$data_new = json_encode($data_new);
$contract->at($contractAddress)->send($functionName, 5678, $data_new, function ($err, $transres) use (&$done) {
if ($err) {
echo 'error: ' . $err->getMessage() . "<br>";
} else {
$done = $transres;
}
}); //FIXME: Wrong type of eth_sendTransaction method argument 0`
The text was updated successfully, but these errors were encountered:
hafizah65
changed the title
error trying to send data
trouble trying to send data
Sep 13, 2023
i'm trying to send the data but i got the following error. i managed to get an existing data from the blockchain, but sending gives out either "Please make sure you have put all function params and callback"
solidity function
php
i'm not exactly sure what i've done wrong. i've tried following #238 and i got "Wrong type of eth_sendTransaction method argument 0"
The text was updated successfully, but these errors were encountered: