mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 11:45:50 +00:00
* Create create_price_oracle.py * Create README.md * Update README.md * Update create_price_oracle.py * Create delete_price_oracle.py * Update delete_price_oracle.py * Create account_price_oracles.py * Create did_set.py * Create did_delete.py * Create account_did.py * Create requirements.txt * Create README.md * Create requirements.txt * Update README.md * Update README.md * Create README.md * Create README.md * Update did_set.py * Update did_set.py * Update did_set.py * Update did_delete.py * Update README.md * Update create_price_oracle.py * Update did_set.py * Update README.md * Update README.md * Update delete_price_oracle.py * Update README.md
58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
# This allows you to create or update a DID
|
|
from xrpl.models import DIDSet
|
|
from xrpl.clients import JsonRpcClient
|
|
from xrpl.wallet import generate_faucet_wallet
|
|
from xrpl.transaction import submit_and_wait
|
|
from xrpl.utils import str_to_hex
|
|
|
|
|
|
# connect to the xrpl via a client
|
|
print("Connecting to client")
|
|
client = JsonRpcClient("https://s.altnet.rippletest.net:51234")
|
|
print("connected!!!")
|
|
|
|
|
|
# define/generate a wallet / account
|
|
account_did_creator = generate_faucet_wallet(client)
|
|
|
|
print("⭐successfully generated wallet")
|
|
print("here's your seed. You'll need it to modify and delete the DID set by this account/wallet")
|
|
# it is not good practise to expose your seed.
|
|
print(f"seed: {account_did_creator.seed}")
|
|
|
|
|
|
# define the document associated with the DID
|
|
document = "did:example:123#public-key-0"
|
|
|
|
# define the data associated with the DID
|
|
# The public attestations of identity credentials associated with the DID.
|
|
data = "did:example:123#key-1"
|
|
|
|
# define the uri associated with the DID
|
|
# The Universal Resource Identifier associated with the DID.
|
|
uri = "https://example.did.com/123"
|
|
|
|
|
|
# build DID SET transaction
|
|
# str_to_hex() converts the inputted string to blockchain understandable hexadecimal
|
|
did_set_txn = DIDSet(
|
|
account=account_did_creator.address,
|
|
did_document=str_to_hex(document),
|
|
data=str_to_hex(data),
|
|
uri=str_to_hex(uri),
|
|
)
|
|
|
|
|
|
# sign, submit the transaction and wait for the response
|
|
print("siging and submitting the transaction, awaiting a response")
|
|
did_set_txn_response = submit_and_wait(
|
|
transaction=did_set_txn, client=client, wallet=account_did_creator
|
|
)
|
|
|
|
# Parse response for result
|
|
did_set_txn_result = did_set_txn_response.result
|
|
|
|
# Print result and transaction hash
|
|
print(did_set_txn_result["meta"]["TransactionResult"])
|
|
print(did_set_txn_result["hash"])
|