Developer's Hub
v1.0
TransactionPack()
Copy Markdown
Open in ChatGPT
Open in Claude
Summary
Route | Type | Example |
|---|---|---|
/Transaction/Pack | POST |
Description
Packs a transaction to a byte array
This is needed for sending a transaction
Request
Request Structure
{
// parameters common for all requests
"MethodApi" : "string_value", // API method name to form and process a transaction
"PublicKey":"string_value", // Sender public key in Base58
"ReceiverPublicKey":"string_value", // Recipient public key in Base58
“Amount”:decimal, // Transaction amount
"Fee":decimal, // Maximum fee approved by the user
"SmartContractSource":"String_value", //Source code of smart contract
“UserData”:”string_value” // If needed extra information can be stored inside UserData
}
Request Parameters
MethodApi: string value - it’s vital to specify the API method to pack the transaction: "TransferToken", "TransferCs", "Delegation", "SmartDeploy", "SmartMethodExecute";
PublicKey: string_value - sender public key in base58
ReceiverPublicKey: string_value - recipient public key in base58
Amount: decimal - transaction amount as a decimal or integer number
Fee: decimal - maximum fee approved by the user as a decimal or integer number
UserData: string_value - data the user sent with the transaction including the data about deployment and initiation of a smart contract
Response
Response Structure
"dataResponse":{
"transactionPackagedStr":"String_Value" // packed transaction as a string in base58
},
Example Code
import requests
import json
def Transaction_Pack():
url = 'http://apinode.credits.com/api/Transaction/Pack'
headers = {
'Content-type': 'application/json'
, 'Accept': 'application/json'
, 'Content-Encoding': 'utf-8'
}
data = {
"NetworkAlias":"Testnet"
, "MethodApi" : "TransferCs"
, "PublicKey":"EnrT42AkUpe32xw1tXE4e3siGMExpRe7uvsgNj36RzLc"
, "ReceiverPublicKey":"4SFfA1S2xfA3BdgkTn2tK14yDhLuD11RVz78kqx35jct"
, "Amount":0.1
, "Fee":1
, "UserData":"" }
answer = requests.post(url, data=json.dumps(data), headers=headers)
if answer.status_code == 200:
response = answer.text
return response
print(Transaction_Pack())
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Program.Getinfo
{
public class PackTransaction
{
static readonly HttpClient client = new HttpClient();
public class body
{
public string authKey { get; set; }
public string networkAlias { get; set; }
public string MethodApi { get; set; }
public string PublicKey { get; set; }
public string ReceiverPublicKey { get; set; }
public double Amount { get; set; }
public double Fee { get; set; }
public string UserData { get; set; }
}
public static async Task Main()
{
try
{
#include <iostream>
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
using namespace utility; // Common utilities like string conversions
using namespace web; // Common features like URIs.
using namespace web::http; // Common HTTP functionality
using namespace web::http::client; // HTTP client features
using namespace concurrency::streams; // Asynchronous streams
using namespace web::json;
int main(int argc, char* argv[])
{
web::json::value json_v;
web::json::value json_return;
json_v[L"authKey"] = web::json::value::string(L"");
json_v[L"NetworkAlias"] = web::json::value::string(L"Testnet");
json_v[L"MethodApi"] = web::json::value::string(L"TransferCs");
Last updated on
Credits Protocol
Getting Started
API Reference
Developers Journal
Powered by
