Sir, if i wan transfer my sui in my account, what should i do with pysui?
Closed this issue · 7 comments
i have install pysui, sui-binaries.
can u give me a exsample?
like payallsui
There are other transaction commands on SuiTransaction
# Copyright Frank V. Castellucci
# SPDX-License-Identifier: Apache-2.0
# -*- coding: utf-8 -*-
"""Sample script for simple transfer using GraphQL."""
from pysui import SuiConfig, SuiRpcResult
from pysui.sui.sui_pgql.pgql_sync_txn import SuiTransaction
from pysui.sui.sui_pgql.pgql_clients import SuiGQLClient
from pysui.sui.sui_pgql.pgql_txb_signing import SignerBlock
import pysui.sui.sui_pgql.pgql_query as qn
def handle_result(result: SuiRpcResult) -> SuiRpcResult:
"""."""
if result.is_ok():
if hasattr(result.result_data, "to_json"):
print(result.result_data.to_json(indent=2))
else:
print(result.result_data)
else:
print(result.result_string)
if result.result_data and hasattr(result.result_data, "to_json"):
print(result.result_data.to_json(indent=2))
else:
print(result.result_data)
return result
def do_execute_transfer(client: SuiGQLClient):
"""Execute a transaction.
The result contains the digest of the transaction which can then be queried
for details
This uses the new SuiTransaction (GraphQL RPC based)
"""
txer: SuiTransaction = SuiTransaction(client=client)
scres = txer.split_coin(coin=txer.gas, amounts=[1000000000])
txer.transfer_objects(
transfers=scres, recipient=client.config.active_address.address
)
tx_b64 = txer.build()
signing_block: SignerBlock = txer.signer_block
rsig_array = signing_block.get_signatures(config=client.config, tx_bytes=tx_b64)
handle_result(
client.execute_query_node(
with_node=qn.ExecuteTransaction(tx_bytestr=tx_b64, sig_array=rsig_array)
)
)
if __name__ == "__main__":
# Setup configuration and GraphQL client
cfg = SuiConfig.default_config()
client_init = SuiGQLClient(
write_schema=False,
config=cfg,
)
print(f"Schema base version {client_init.base_schema_version}")
print(f"Schema full version {client_init.schema_version}")
# Execute transfer coin
do_execute_transfer(client_init)
# Close
client_init.client.close_sync()
thx ,sir i m newbie
cfg = SuiConfig.user_config(
rpc_url= "",
prv_keys=[{'wallet_key': 'suiprivkey1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'key_scheme': SignatureScheme.SECP256R1}],
)
what should i do to this config? thx for your time.
thx ,sir i m newbie cfg = SuiConfig.user_config( rpc_url= "", prv_keys=[{'wallet_key': 'suiprivkey1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'key_scheme': SignatureScheme.SECP256R1}], ) what should i do to this config? thx for your time.
this privkey cant work well here, lenth 70 > 66
Sir, when i use keypair_from_keystring func. i always got this:"PubKey 3H123123123674=, PrivKey Private". why i cant see my private key? i need it
@Crawlling Posting questions here as well as the Discord channel is redundant. Use one or the other so I'm not answering twice.
Thank you.
@Crawlling Posting questions here as well as the Discord channel is redundant. Use one or the other so I'm not answering twice.
Thank you.
Thx, sir. i already solve this problem. thx you for your time.