You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

技术问询:如何使用Python API在Neblio测试网发行代币?

Complete Implementation for Issuing NTP1 Tokens on Neblio Testnet via Python API

Got it, let's wrap up your NTP1 token issuance code for Neblio's testnet. You've got the initial setup right, but we need to fill in missing required fields, handle transaction signing, and broadcast the finalized transaction to the network. Here's the full working implementation:

from __future__ import print_function
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint

# Configure the API to use Neblio's testnet endpoint
swagger_client.configuration.host = "https://testnet.nebl.io"

# Create instances of the required API classes
ntp1_api = swagger_client.TestnetNTP1Api()
transaction_api = swagger_client.TestnetTransactionApi()

# Initialize the token issuance request object
body = swagger_client.IssueTokenRequest()

# --------------------------
# Fill in required token details
# --------------------------
# Address issuing the token (your testnet address)
body.issue_address = "TUfp4Ss95xaKQPNGpbiZDsMPe4NR16CDiL"
# Total supply of the token
body.amount = 1000
# Divisibility: 0 = token is non-divisible (whole units only), 8 = like Bitcoin (up to 8 decimals)
body.divisibility = 0
# Token symbol (max 8 characters)
body.symbol = "MYTST"
# Token name (max 32 characters)
body.name = "My Test NTP1 Token"
# Transaction fee (in satoshis; 10000 is sufficient for testnet)
body.fee = 10000

# Optional: Add extra metadata (remove if not needed)
body.description = "A test token issued via Neblio's Python API"
body.url = "https://example.com/mytoken"

try:
    # Step 1: Build the unsigned token issuance transaction
    print("Building unsigned transaction...")
    unsigned_tx = ntp1_api.build_issue_token(body)
    pprint(unsigned_tx)

    # Step 2: Sign the transaction with your private key
    # Replace YOUR_TESTNET_PRIVATE_KEY with the private key for your issue_address
    private_key = "YOUR_TESTNET_PRIVATE_KEY"
    signed_tx = transaction_api.sign_transaction(unsigned_tx, private_key)
    print("\nSigned transaction:")
    pprint(signed_tx)

    # Step 3: Broadcast the signed transaction to the testnet
    print("\nBroadcasting transaction...")
    broadcast_response = transaction_api.broadcast_transaction(signed_tx)
    print("Transaction broadcast successful!")
    pprint(broadcast_response)

except ApiException as e:
    print("Exception when calling API: %s\n" % e)

Key Notes:

  • Divisibility: Adjust the divisibility value based on your token's needs. Use 0 if you want tokens to only exist as whole units, or a higher number (up to 8) for divisible tokens.
  • Private Key: You must replace YOUR_TESTNET_PRIVATE_KEY with the actual private key associated with the issue_address you specified. Never share your private key publicly!
  • Token Limits: The symbol can't exceed 8 characters, and name is limited to 32 characters. Stick to these limits to avoid API errors.
  • Fee: The fee value of 10000 satoshis is more than enough for testnet transactions. You can adjust it, but keep it above the minimum network fee to ensure the transaction is processed.

Once you run this code successfully, you'll get a transaction ID in the broadcast response. You can verify the token issuance using Neblio's testnet block explorer by searching for this transaction ID.

内容的提问来源于stack exchange,提问作者Kamil Septio Trojnar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 08:26:38