Closed Razorholt closed 2 years ago
Hello,
Try in this way. Adapt it to your code.
$data = $this->contractInstance->getData('addToCommunityList', $yourAddressList);
// Build transaction
$transaction = new Transaction([
'nonce' => $nonce,
'from' => $fromAddress,
'to' => $contractAddress,
'gasPrice' => $gasPrice,
'gasLimit' => $gasLimit,
'value' => '0x0',
'data' => sprintf('0x%s', $data),
'chainId' => $chainId,
]);
// Sign transaction
$signedTx = $transaction->sign($fromAddressKey);
$txId = '';
// Send transaction
$this->web3->getEth()->sendRawTransaction(sprintf('0x%s', $signedTx), function ($err, $tx) use (&$txId) {
if ($err !== null) {
throw new \Exception($err->getMessage());
}
$txId = $tx;
});
echo $txId;
Dependency: ethereum-tx
Works perfectly! Thank you so much @samyan !!
I have this function in the smart contract that I would like to call from PHP:
How do I sign this?
Thank you!