My key is getting rejected all the time. Why is that ?
Here is my code :
import requests
import json
from web3 import Web3, HTTPProvider
# Define your relay and ERC20 token details
RELAYER_API_KEY = 'your-relayer-api-key'
RELAYER_SECRET_KEY = 'your-relayer-secret-key'
RELAYER_URL = 'https://api.defender.openzeppelin.com/relayer'
ERC20_TOKEN_ADDRESS = 'your-erc20-token-address'
MY_WALLET_ADDRESS = 'your-wallet-address'
# Define the user's private key
USER_PRIVATE_KEY = 'user-private-key'
# Initialize web3
web3 = Web3(HTTPProvider('https://rpc-mumbai.matic.today'))
# Define the ERC20 transfer function signature
TRANSFER_FUNCTION_SIGNATURE = web3.sha3(text='transfer(address,uint256)').hex()[0:10]
# Define the amount of tokens to transfer (2 tokens with 0 decimals)
TOKEN_AMOUNT = web3.toHex(2)
# Define the data to be sent in the transaction
data = TRANSFER_FUNCTION_SIGNATURE + \
web3.toHex(web3.toBytes(hexstr=MY_WALLET_ADDRESS)).rjust(64, '0') + \
TOKEN_AMOUNT.rjust(64, '0')
# Define the headers for the HTTP requests
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Api-Key': RELAYER_API_KEY,
'Authorization': f'Bearer {RELAYER_SECRET_KEY}'
}
# Define the payload for the transaction
payload = {
'to': ERC20_TOKEN_ADDRESS,
'value': '0x0',
'speed': 'fast',
'gasLimit': '0x5208', # 21000 in hexadecimal
'data': data
}
# Send the transaction
response = requests.post(f'{RELAYER_URL}/txs', headers=headers, data=json.dumps(payload))
# Print the response
print(response.json())
Here is the message i receive :
{'message': "'<secretkey>' not a valid key=value pair (missing equal-sign) in Authorization header: 'Bearer <secretkey>'."}