使用Soroban Python SDK部署包裹的令牌合同
#python #soroban #sorobanathon #stellar

在我的previous post中,我向您展示了如何使用Soroban Python SDK发送付款。在这篇文章中,我们将使用Soroban Python SDK部署包裹的令牌合同。

准备

首先,创建一个Futurenet帐户,该帐户将用于部署并充当令牌合同的管理员。 Create account at Stellar Laboratory and make sure to fund them. The account that i will be using :

Public Key  GATQFKA7BV7LYYE6UJ2LRL56W3BZRRSWTINA6TG2EM5CCDORFIERAKWV
Secret Key  SCHKLGAGY7QGWUKUFDGHEQMSCPFZNMLEHQE6Y6WPGYGHQIM23T3NJE3C

然后,我们要使用的Python脚本是Soroban Python SDK Examples Github Repositorykoude0。这些示例由overcat(Soroban Python SDK的维护者)撰写。

部署包裹的令牌合同

要部署合同,打开soroban_deploy_create_wrapped_token_contract.py文件,您可以调整以下一些参数:

secret = "SCHKLGAGY7QGWUKUFDGHEQMSCPFZNMLEHQE6Y6WPGYGHQIM23T3NJE3C"
rpc_server_url = "https://horizon-futurenet.stellar.cash:443/soroban/rpc"
network_passphrase = Network.FUTURENET_NETWORK_PASSPHRASE
hello_asset = Asset("HELLO", "GATQFKA7BV7LYYE6UJ2LRL56W3BZRRSWTINA6TG2EM5CCDORFIERAKWV")

secret-部署合同的秘密密钥
rpc_server_url -RPC服务器URL用于部署合同
network_passphrase -futurenet网络密码
hello_asset-资产和帐户公钥发行人的符号(admin)

使用更改保存soroban_deploy_create_wrapped_token_contract.py文件,然后使用此命令将脚本运行在命令提示符中:

python soroban_deploy_create_wrapped_token_contract.py

结果:

$ python soroban_deploy_create_wrapped_token_contract.py
simulated transaction: error=None results=[SimulateTransactionResult(auth=None, footprint='AAAAAAAAAAMAAAAGrAPyVAexHS7Lfq1Dh8TlMLNLMSrdfI/FPXD9Brh90u8AAAADAAAAAwAAAAasA/JUB7EdLst+rUOHxOUws0sxKt18j8U9cP0GuH3S7wAAAAQAAAABAAAAAAAAAAEAAAAFAAAABUFkbWluAAAAAAAABqwD8lQHsR0uy36tQ4fE5TCzSzEq3XyPxT1w/Qa4fdLvAAAABAAAAAEAAAAAAAAAAQAAAAUAAAAITWV0YWRhdGE=', xdr='AAAABAAAAAEAAAAGAAAAIKwD8lQHsR0uy36tQ4fE5TCzSzEq3XyPxT1w/Qa4fdLv')] cost=SimulateTransactionCost(cpu_insns=110198, mem_bytes=6463) latest_ledger=572498
setting footprint and signing transaction...
sent transaction: id='eaf6b55ae79ae6202aaff6eecbd9f69b017608ff73a719c89e8929def19ddddd' status=<TransactionStatus.PENDING: 'pending'> error=None
waiting for transaction to be confirmed...
waiting for transaction to be confirmed...
waiting for transaction to be confirmed...
transaction status: id='eaf6b55ae79ae6202aaff6eecbd9f69b017608ff73a719c89e8929def19ddddd' status=<TransactionStatus.SUCCESS: 'success'> envelope_xdr='AAAAAgAAAABtb05lTpeOTUrHyRo/keRPQ+/Rp4LYwgi2VXWHWl4XYAAAAGQACLppAAAABQAAAAEAAAAAAAAAAAAAAABkHHKJAAAAAAAAAAEAAAABAAAAAG1vTmVOl45NSsfJGj+R5E9D79GngtjCCLZVdYdaXhdgAAAAGAAAAAEAAAACAAAAAkhFTExPAAAAAAAAAAAAAABtb05lTpeOTUrHyRo/keRPQ+/Rp4LYwgi2VXWHWl4XYAAAAAEAAAAAAAAAAwAAAAasA/JUB7EdLst+rUOHxOUws0sxKt18j8U9cP0GuH3S7wAAAAMAAAADAAAABqwD8lQHsR0uy36tQ4fE5TCzSzEq3XyPxT1w/Qa4fdLvAAAABAAAAAEAAAAAAAAAAQAAAAUAAAAFQWRtaW4AAAAAAAAGrAPyVAexHS7Lfq1Dh8TlMLNLMSrdfI/FPXD9Brh90u8AAAAEAAAAAQAAAAAAAAABAAAABQAAAAhNZXRhZGF0YQAAAAAAAAAAAAAAAVpeF2AAAABAdx8pRxv6iGWD0ma0uuFV3oKebeDuaC7j80frOO7vKDwP49aWa2sFKVJ2fjph3Xj52lgSs/mNycYXJeSI8OSAAQ==' result_xdr='AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAAY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SsfJGj+R5E9D79GngtjCCLZVdYdaXhdgAAAAAAAAAAAAAAABAAAAAAAAAAAAAABkAAAAAAAAAAEAAAAAAAAAGAAAAAAAAAAEAAAAAQAAAAYAAAAgrAPyVAexHS7Lfq1Dh8TlMLNLMSrdfI/FPXD9Brh90u8AAAAA02fs2dDFBdR8GlynM9VeTwbQ7ckYHpu6eEGF9i75+6LLvEh1Deu4U1CTs96viKx/TP+HQlV2pY3iusdUrNtGFiH5L17VhmgoiSxLNEvY5WWYvlN1y13OW61N4hIpVn6q' results=[SCVal(xdr='AAAABAAAAAEAAAAGAAAAIKwD8lQHsR0uy36tQ4fE5TCzSzEq3XyPxT1w/Qa4fdLv')] error=None
contract id: ac03f25407b11d2ecb7ead4387c4e530b34b312add7c8fc53d70fd06b87dd2ef

从上面的结果中,我们获得了已部署的令牌合同的合同ID,即ac03f25407b11d2ecb7ead4387c4e530b34b312add7c8fc53d70fd06b87dd2ef

从合同ID中,管理员可以执行各种令牌操作,例如薄荷,刻录,设置管理员等。有关代币操作的更多信息,您可以检查here

现在,我们将使用Soroban CLI检查我们的令牌包裹合同的symbol。我们将使用此命令:

$ soroban contract invoke --id ac03f25407b11d2ecb7ead4387c4e530b34b312add7c8fc53d70fd06b87dd2ef --secret-key SAM7O4V6QBSBQPM64IWSTCUOGN34QK6VI4RGWZERNE2OBXHVRCH2VU2V --fn symbol
success
"48454c4c4f"

从返回的值中,我们得到48454c4c4f,在十六进制中。转换为字符串时,它变成“ Hello”。

关闭

在这篇博客文章中,我们已经介绍了使用Soroban Python SDK部署包裹的令牌合同的步骤。您可以尝试部署自己的令牌,并尝试使用Soroban-Cli等其他代币操作,例如薄荷,燃烧等。