Replies: 9 comments 6 replies
-
This is awesome! Thanks for submitting! We will start reviewing submissions for rewards this week, and will check in on this thread with any questions, feedbacks, or updates. But yeah: great submission! |
Beta Was this translation helpful? Give feedback.
-
Heya Overcat, Please let us know if you have any questions. (You can also message me on discord @ anuxhya) All the best, |
Beta Was this translation helpful? Give feedback.
-
@overcat Thanks for exploring how the Python SDK would expose invocations. One thing I noticed is that the I really like that the Maybe the current function could be |
Beta Was this translation helpful? Give feedback.
-
Support for deploying contracts has been added, here is an example. |
Beta Was this translation helpful? Give feedback.
-
The Python SDK now supports building the signatures required to call contract functions. from stellar_sdk import Network, Keypair
from stellar_sdk.soroban_types import Ed25519Identifier, SignaturePayload
from stellar_sdk.soroban_types import Int128
secret = "SAAPYAPTTRZMCUZFPG3G66V4ZMHTK4TWA6NS7U4F7Z3IMUD52EK4DDEV"
network_passphrase = Network.FUTURENET_NETWORK_PASSPHRASE
kp = Keypair.from_secret(secret)
action_name = "increment"
contract_id = "3770d1476b54e803be56832e3c461daaec862e3a0620cf53a1c9f4028809d38b"
nonce = Int128(0)
signature_payload = SignaturePayload(
network_passphrase, contract_id, action_name, [Ed25519Identifier(kp), nonce]
)
ed25519_signature = signature_payload.ed25519_sign(kp)
print(f"signature: {ed25519_signature.signature.hex()}")
print(f"signature object: {ed25519_signature._to_xdr_sc_val().to_xdr()}") You can find an example here: https://github.com/StellarCN/py-stellar-base/blob/soroban/examples/soroban_invoke_auth_advanced_contract.py |
Beta Was this translation helpful? Give feedback.
-
In addition, we have introduced some classes to help make it easier to build the parameters needed to call contract functions. They are currently located in stellar_sdk.soroban_types, which can free users from constructing SCObject (in most scenarios), and I am considering adding more related classes. After introducing these classes: account = AccountIdentifier(kp) Before introducing these classes: account = stellar_xdr.SCVal(
stellar_xdr.SCValType.SCV_OBJECT,
obj=stellar_xdr.SCObject(
stellar_xdr.SCObjectType.SCO_VEC,
vec=stellar_xdr.SCVec(
sc_vec=[
stellar_xdr.SCVal(
stellar_xdr.SCValType.SCV_SYMBOL,
sym=stellar_xdr.SCSymbol("Account".encode()),
),
stellar_xdr.SCVal(
stellar_xdr.SCValType.SCV_OBJECT,
obj=stellar_xdr.SCObject(
stellar_xdr.SCObjectType.SCO_ACCOUNT_ID,
account_id=kp.xdr_account_id(),
),
),
]
),
),
) |
Beta Was this translation helpful? Give feedback.
-
Stellar Quest 5 is an excellent material to learn about Soroban, and I've prepared Python solutions to help you understand how to use the Python SDK. Check out: https://github.com/overcat/stellar-quest-solutions |
Beta Was this translation helpful? Give feedback.
-
If you are a developer looking to add support for Soroban in other SDKs, here is a checklist to help you get started. This checklist will also be updated as development progresses. Please let me know if you have any suggestions. Please note that the implementation of Python is still in progress and the code implementation may change at any time. Checklist:
|
Beta Was this translation helpful? Give feedback.
-
Stellar Python SDK now supports Soroban Preview 7, which includes support for Auth Next. An example of building alice_root_invocation = AuthorizedInvocation(
contract_id=atomic_swap_contract_id,
function_name="swap",
args=[
Bytes(binascii.unhexlify(native_token_contract_id)), # token_a
Bytes(binascii.unhexlify(cat_token_contract_id)), # token_b
Int128(1000), # amount_a
Int128(4500), # min_b_for_a
],
sub_invocations=[
AuthorizedInvocation(
contract_id=native_token_contract_id,
function_name="incr_allow",
args=[
Address(alice_kp.public_key), # owner
Address.from_raw_contract(atomic_swap_contract_id),
Int128(1000),
],
sub_invocations=[],
)
],
)
alice_contract_auth = ContractAuth(
address=Address(alice_kp.public_key),
nonce=alice_nonce,
root_invocation=alice_root_invocation,
)
alice_contract_auth.sign(alice_kp, network_passphrase) |
Beta Was this translation helpful? Give feedback.
-
Initial support for Soroban has now been added to the Stellar Python SDK, and I'm happy to share an example here to show how to use it.
Prerequisite
pip install git+https://github.com/StellarCN/py-stellar-base.git@soroban
Code Example
Copy from https://github.com/StellarCN/py-stellar-base/blob/soroban/examples/soroban_invoke_contract_function.py
Expected output
Beta Was this translation helpful? Give feedback.
All reactions