{"id":18839154,"url":"https://github.com/starcoinorg/starcoin-sdk-python","last_synced_at":"2025-04-14T06:51:11.836Z","repository":{"id":47287440,"uuid":"319889136","full_name":"starcoinorg/starcoin-sdk-python","owner":"starcoinorg","description":null,"archived":false,"fork":false,"pushed_at":"2022-04-07T03:03:20.000Z","size":121,"stargazers_count":10,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T21:49:35.495Z","etag":null,"topics":["sdk-python","starcoin"],"latest_commit_sha":null,"homepage":"https://starcoin-sdk-python.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/starcoinorg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-09T08:21:06.000Z","updated_at":"2022-12-29T08:54:46.000Z","dependencies_parsed_at":"2022-09-10T11:02:00.825Z","dependency_job_id":null,"html_url":"https://github.com/starcoinorg/starcoin-sdk-python","commit_stats":null,"previous_names":["fikgol/starcoin-sdk-python"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starcoinorg%2Fstarcoin-sdk-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starcoinorg%2Fstarcoin-sdk-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starcoinorg%2Fstarcoin-sdk-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starcoinorg%2Fstarcoin-sdk-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/starcoinorg","download_url":"https://codeload.github.com/starcoinorg/starcoin-sdk-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837274,"owners_count":21169373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sdk-python","starcoin"],"created_at":"2024-11-08T02:42:01.576Z","updated_at":"2025-04-14T06:51:11.810Z","avatar_url":"https://github.com/starcoinorg.png","language":"Python","readme":"# starcoin-sdk-python\n## Document\n\nThe document of starcoin sdk for python: [documents site](https://starcoin-sdk-python.readthedocs.io/en/latest/).\n\n## Pypi package\n\nhttps://pypi.org/project/starcoin-sdk-python/\n\n## Usage\n``` python\nfrom starcoin import starcoin_types as types\nfrom starcoin import starcoin_stdlib as stdlib\nfrom starcoin import serde_types as st\nfrom starcoin.sdk import (utils, client, local_account, auth_key)\nfrom starcoin.sdk.receipt_identifier import ReceiptIdentifier\nfrom cryptography.hazmat.primitives.asymmetric.ed25519 import (\n    Ed25519PrivateKey, Ed25519PublicKey)\n\t\n# create a client for connecting starcoin node\ncli = client.Client(\"https://barnard-seed.starcoin.org\")\n\n# get the node info\nprint(cli.node_info())\n\n# get the resource of account\naccount_resource = cli.state_get(\n        '0x00000000000000000000000000000001/1/0x00000000000000000000000000000001::Account::Account')\nprint(account_resource)\n\n# create a account with your private key\nprivate_key = Ed25519PrivateKey.from_private_bytes(bytes.fromhex(\n\"e424e16db235e3f3b9ef2475516c51d4c15aa5287ceb364213698bd551eab4f2\"))\naccount = local_account.LocalAccount(private_key)\n\n# define a transfer function\ndef transfer(cli: client.Client, sender: local_account.LocalAccount, receipt: str, amount: st.uint128):\n    seq_num = cli.get_account_sequence(\n        \"0x\"+sender.account_address.bcs_serialize().hex())\n    receipt = ReceiptIdentifier.decode(receipt)\n    script = stdlib.encode_peer_to_peer_v2_script_function(\n        token_type=utils.currency_code(\"STC\"),\n        payee=receipt.account_address,\n        amount=amount,\n    )\n    node_info = cli.node_info()\n    now_seconds = int(node_info.get('now_seconds'))\n    # expired after 12 hours\n    expiration_timestamp_secs = now_seconds + 43200\n    raw_txn = types.RawUserTransaction(\n        sender=sender.account_address,\n        sequence_number=seq_num,\n        payload=script,\n        max_gas_amount=10000000,\n        gas_unit_price=1,\n        gas_token_code=\"0x1::STC::STC\",\n        expiration_timestamp_secs=expiration_timestamp_secs,\n        chain_id=types.ChainId(st.uint8(251)),\n    )\n    txn = sender.sign(raw_txn)\n    print(cli.submit(txn))\n\n```\n\nMore examples see [examples](https://github.com/starcoinorg/starcoin-sdk-python/tree/master/examples)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarcoinorg%2Fstarcoin-sdk-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstarcoinorg%2Fstarcoin-sdk-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarcoinorg%2Fstarcoin-sdk-python/lists"}