Hello i m trying to claim my vesting token with python. but can't do it where am i making mistake.
i have to call this function on contract for claiming tokens.
step 1 -> function release(bytes32 _vestingScheduleId)
for getting _vestingScheduleId i m calling this function
step 2 - function computeNextVestingScheduleIdForHolder(address _holder)
response of step2 is - b':1%\xedmrGS(\xcc\xdc\x14\x104|\x12%"\xceo\xf2\xe5\x19\t\xbd\xad\xc8\xf0\x11{\x9d8'
i m trying to pass this response to at step 1 function but getting error i m trying to pass argument as converting response to hex() but still getting error.
import requests
import web3.eth
from web3 import Web3
import time, json
class InteractBSC():
def __init__(self):
self.bsc = "https://bsc-dataseed.binance.org/"
self.web3 = Web3(Web3.HTTPProvider(self.bsc))
self.my_address = "0x41d90cb6F9Ff46cAfE17552DEA8e3672f6170E6B"
self.contract_address = "0x35Bb6Dd4E8C63491057c32621c8cDdE43BabE201"
self.contract = ""
self.private = "my private key"
def is_connected(self):
return self.web3.isConnected()
def get_contract(self, contract_address=""):
url_eth = "https://api.bscscan.com/api"
api_endpoint = url_eth + "?module=contract&action=getabi&address=" + str(self.contract_address)
r = requests.get(url=api_endpoint)
response = r.json()
abi = json.loads(response["result"])
for i in abi:
print(i)
self.contract = self.web3.eth.contract(address=self.contract_address, abi=abi)
return self.contract
def claim_token(self, schedule_id):
txn = self.contract.functions.release(schedule_id).buildTransaction({
"from": self.my_address,
"value": 0,
"gas": 500000,
"gasPrice": self.web3.toWei(5, "gwei"),
"nonce": self.get_my_nonce()})
signedtx = self.web3.eth.account.sign_transaction(txn, private_key=self.private)
return self.web3.eth.send_raw_transaction(signedtx.rawTransaction)
def get_my_nonce(self):
return self.web3.eth.getTransactionCount(self.my_address, 'latest')
def compute_schedule_id(self):
return contract.functions.computeNextVestingScheduleIdForHolder(self.my_address)
xobj = InteractBSC()
contract = xobj.get_contract()
my_id = xobj.compute_schedule_id()
resp = xobj.claim_token(my_id)
# resp = xobj.claim_token(my_id.hex())