-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
The example listed here and copied below doesn't work.
from radix_engine_toolkit import *
from typing import Tuple
import secrets
def new_account(network_id: int) -> Tuple[PrivateKey, PublicKey, Address]:
"""
Creates a new random Ed25519 private key and then derives the public key and
the account address associated with it
"""
private_key_bytes: bytes = secrets.randbits(256).to_bytes(32)
private_key: PrivateKey = PrivateKey.new_ed25519(list(private_key_bytes))
public_key: PublicKey = private_key.public_key()
account: Address = derive_virtual_account_address_from_public_key(
public_key, network_id
)
return (private_key, public_key, account)
def random_nonce() -> int:
"""
Generates a random secure random number between 0 and 0xFFFFFFFF (u32::MAX)
"""
return secrets.randbelow(0xFFFFFFFF)
# A constant of the id of the network
NETWORK_ID: int = 0x02
(private_key1, public_key1, account1) = new_account(NETWORK_ID)
(private_key2, public_key2, account2) = new_account(NETWORK_ID)
print(f"Address of account 1: {account1.as_str()}")
Error
(private_key1, public_key1, account1) = new_account(NETWORK_ID)
Traceback (most recent call last):
File "/app/.venv/lib/python3.12/site-packages/radix_engine_toolkit/__init__.py", line 13582, in write
memoryview(value)
TypeError: memoryview: a bytes-like object is required, not 'list'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 7, in new_account
File "/app/.venv/lib/python3.12/site-packages/radix_engine_toolkit/__init__.py", line 21334, in new_ed25519
_UniffiConverterBytes.lower(bytes),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/radix_engine_toolkit/__init__.py", line 493, in lower
cls.write(value, builder)
File "/app/.venv/lib/python3.12/site-packages/radix_engine_toolkit/__init__.py", line 13584, in write
raise TypeError(
TypeError: a bytes-like object is required, not 'list'
python --version
Python 3.12.3
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels