#퍼블릭노드에 접속합니다
w3 = Web3(Web3.HTTPProvider(“https://public-node-api.klaytnapi.com/v1/cypress”))
#컨트렉트주소는 클레이스왑입니다
contract_address = Web3.toChecksumAddress(“0xC6a2Ad8cC6e4A7E08FC37cC5954be07d499E7654”)
contract = w3.eth.contract(address=contract_address, abi=abi)
#프라이빗키를 언락합니다
account = Account.from_key(private_key)
account_address = account.address
w3.eth.default_account = account_address
nonce = w3.eth.get_transaction_count(account_address)
해당 TX를 작성합니다
tx = {
‘to’: contract_address,
‘data’: contract.functions.exchangeKctPos(tokenA_address, amountA, tokenB_address, amountB, path).buildTransaction(),
‘value’: 0,
‘nonce’: nonce,
‘gas’: 75000,
‘maxFeePerGas’: 50000000000,
‘maxPriorityFeePerGas’: 2000000000,
‘chainId’: 8217
}
Sign the transaction
signed_tx = Account.sign_transaction(tx, private_key)
Send the transaction to the network
tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
Wait for the transaction to be mined
receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
Print the transaction receipt
print(receipt)
해당 클레이스왑 exchangeKctPos 의 함수를 실행하고 tx를 받아볼려고하는데
해당 알람이 왜 뜨는지 모르겠습니다…
어떤 양식이 잘못된걸까요?
Traceback (most recent call last):
File “C:\Users\asdas\OneDrive\바탕 화면\깃허브\Klayswap\call_exchange.py”, line 69, in
‘data’: contract.functions.exchangeKctPos(tokenA_address, amountA, tokenB_address, amountB, path).buildTransaction(),
AttributeError: ‘exchangeKctPos’ object has no attribute ‘buildTransaction’
abi에 exchageKctPos를 아무리 살펴봐도 모르겠고
buildTranscation의 양식을 따랐는데 뭐가 문제인지 잘 모르겠습니다.
도움부탁드립니다 감사합니다