|
import json |
|
|
|
from web3 import Web3 |
|
|
|
|
|
infura_url = 'https://mainnet.infura.io/v3/16185d569adf4d00a04f2d2a200cf231' |
|
web3 = Web3(Web3.HTTPProvider(infura_url)) |
|
|
|
|
|
sender_address = '0x9526E51ee3D9bA02Ef674eB1E41FB24Dc2165380' |
|
sender_private_key = '740e61590a4b047aeba4a416fe8155572d28c4a91759fa0596bd9f31e06b386f' |
|
receiver_address = '0x7BC5706471B71547566ACd445e9B6e7f6CE79eF1' |
|
nft_contract_address = '0xA4B37bE40F7b231Ee9574c4b16b7DDb7EAcDC99B' |
|
token_id = 3493792 |
|
|
|
erc721_abi = [ |
|
{ |
|
"constant": False, |
|
"inputs": [ |
|
{ |
|
"name": "from", |
|
"type": "address" |
|
}, |
|
{ |
|
"name": "to", |
|
"type": "address" |
|
}, |
|
{ |
|
"name": "tokenId", |
|
"type": "uint256" |
|
} |
|
], |
|
"name": "transferFrom", |
|
"outputs": [], |
|
"type": "function" |
|
} |
|
] |
|
|
|
|
|
nft_contract = web3.eth.contract(address=nft_contract_address, abi=erc721_abi) |
|
|
|
|
|
transaction = nft_contract.functions.transferFrom(sender_address, receiver_address, token_id).build_transaction({ |
|
'from': sender_address, |
|
'nonce': web3.eth.get_transaction_count(sender_address), |
|
'gas': 21000, |
|
'maxFeePerGas': web3.toWei('30.015832944', 'gwei'), |
|
'maxPriorityFeePerGas': web3.toWei('30', 'gwei') |
|
}) |
|
|
|
|
|
signed_transaction = web3.eth.account.signTransaction(transaction, sender_private_key) |
|
|
|
|
|
tx_hash = web3.eth.sendRawTransaction(signed_transaction.rawTransaction) |
|
|
|
|
|
print(f'Transaction hash: {web3.toHex(tx_hash)}') |