When I run the script transfer_example_subaccount_transfer.py
, I encounter an error, and the script does not work as expected.
Github link : v4-clients/v4-client-py-deprecated/examples/transfer_example_subaccount_transfer.py at main · dydxprotocol/v4-clients · GitHub
Additionally, when I integrate this code into my own project and execute it, I receive various errors in different places. What could be causing this issue, and how can I resolve it?
My output:
python3 transfer_example_subaccount_transfer.py URL must start with one of the following prefixes: "grpc+https", "grpc+http", "rest+https", "rest+http"
My code :
import asyncio
import logging
from v4_client_py.chain.aerial.wallet import LocalWallet
from v4_client_py.clients.dydx_subaccount import Subaccount
from v4_client_py.clients.dydx_validator_client import ValidatorClient
from v4_client_py.clients.constants import BECH32_PREFIX, Network
DYDX_TEST_MNEMONIC = (
""
)
async def main() -> None:
network = Network.config_network()
client = ValidatorClient(network.validator_config)
wallet = LocalWallet.from_mnemonic(DYDX_TEST_MNEMONIC, BECH32_PREFIX)
subaccount = Subaccount(wallet, 0)
try:
tx = client.post.transfer(
subaccount=subaccount,
recipient_address=subaccount.address,
recipient_subaccount_number=1,
asset_id=0,
amount=5_000_000,
)
print("**Transfer Tx**")
print(tx)
except Exception as e:
print(e)
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
asyncio.run(main())