Ich möchte Beträge eines erstellten Tokens von einer Adresse an eine andere senden. Ich möchte eth_sendTransaction verwenden:
eth_sendTransaction
Creates new message call transaction or a contract creation, if the data field contains code.
Parameters
Object - The transaction object
from: DATA, 20 Bytes - The address the transaction is send from.
to: DATA, 20 Bytes - (optional when creating new contract) The address the transaction is directed to.
gas: QUANTITY - (optional, default: 90000) Integer of the gas provided for the transaction execution. It will return unused gas.
gasPrice: QUANTITY - (optional, default: To-Be-Determined) Integer of the gasPrice used for each paid gas
value: QUANTITY - (optional) Integer of the value send with this transaction
data: DATA - The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see Ethereum Contract ABI
nonce: QUANTITY - (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
params: [{
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"gas": "0x76c0", // 30400,
"gasPrice": "0x9184e72a000", // 10000000000000
"value": "0x9184e72a", // 2441406250
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]
The Token uses a basic ERC20 compliant function:
/* Send coins */
function transfer(address _to, uint256 _value) {
if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
balanceOf[msg.sender] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place
}
Einige andere Fragen hier sind in der Nähe und helfen bei eth_call, aber nicht beim Senden von Transaktionen.
So rufen Sie eine Vertragsmethode mit der JSON-RPC-API eth_call auf
Wie kann ich das Augur (REP)-Token-Guthaben meines Kontos über JSON-RPC abrufen?
Ich sehe, Sie sollen den Methodennamen hashen, aber wirklich keine Ahnung, wie Sie die Parameter aufbauen, die an die Transaktion gesendet werden sollen, da es so ist, als würden Sie die ersten 4 Bytes aus der Hash-Signatur hinzufügen und dann eine aufgefüllte Adresse mit links Null hinzufügen.
Bitte helfen Sie mit, den JSON-RPC-Aufruf für eine Smart-Token-Transaktion zu erstellen.
Wenn es in web3.py eine einfache Möglichkeit gibt, dies zu tun, wäre das ebenfalls hilfreich.
Wenn es in web3.py eine einfache Möglichkeit gibt, dies zu tun, wäre das ebenfalls hilfreich.
Sie können einen Vertragsgegenstand mit einem Standard -EIP20-Token- ABI erstellen und ihn dann mit den generierten Methoden aufrufen, wie z. B.:
from web3.contract import ConciseContract
token = web3.eth.contract(
token_contract_address,
abi=EIP20_ABI,
ContractFactoryClass=ConciseContract,
)
token.transfer(
"0xd46e8dd67c5d32be8058bb8eb970870f07244567",
2441406250,
transact={
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"gasPrice": Web3.toWei(4, 'gwei'),
}
)
Randnotizen:
token_contract_address