import {
Connection,
KeyHandler,
IKey,
KeyType,
TransactionHandler,
IBaseTransaction
} from "@activeledger/sdk";
// Setup the connection object to use localhost over http unencrypted
const connection = new Connection("http", "localhost", 5260);
const keyHandler = new KeyHandler();
let key: IKey;
// Generate Elliptic Curve Key and then onboard it
keyHandler.generateKey("keyname", KeyType.EllipticCurve)
.then((generatedKey: IKey) => {
key = generatedKey;
return keyHandler.onboardKey(key, connection)
})
.then((ledgerResp: ILedgerResponse) => {
resolve(ledgerResp);
})
.catch();
// Send the transaction
txHandler.sendTransaction(tx, connection)
.then((response: ILedgerResponse) => {
// Do something with the response
})
.catch();
import activeledger "github.com/activeledger/SDK-Golang";
// Setup a connection to an Activeledger network
activeledger.SetUrl(
sdk.Connection {
Scheme: "http",
Url: "testnet-uk.activeledger.io",
Port: "5260"
}
)
// Create an Elliptic Curve key
privateKey, _ := activeledger.EcdsaKeyGen()
// Onboard the key
// Create the $tx packet
txObject:=activeledger.TxObject{
Namespace:"default",
Contract:"onboard",
Input:input,
Output:output,
ReadOnly:readOnly
}
tx, _ := json.Marshal(txObject)
// Sign
pemPrivate := activeledger.EcdsaFromPem(privatekeyStr)
signedMessage := activeledger.EcdsaSign(pemPrivate, string(tx))
signature["identity"] = signedMessage
selfsign := true
// Create the main transaction body
transaction := activeledger.Transaction{
TxObject: txObject,
SelfSign: selfsign,
Signature: signature
}
// Send the transaction
activeledger.SendTransaction(transaction, activeledger.GetUrl())
// Import the SDK and Transaction helper
use activeledger::{
Connection,
Transaction,
key::EllipticCurve
};
use active_tx::{PacketBuilder, packet_data, signees};
fn main() {
// Setup an unencrypted connection to an Activeledger network
let connection = Connection::new("http://testnet-uk.activeledger.io:5260", false).unwrap();
// Create an Elliptic Curve Key
let key = EllipticCurve::new("key name").unwrap();
let pem = key.get_pem().unwrap();
// Onboard the key
// Create the $i data, then build it
let input = packet_data!({
"key name": {
"type": "secp256k1",
"publicKey": pem.public
}
});
let input_data = PacketBuilder::new(input).build().unwrap();
// Create a transaction builder
let mut tx_builder = TransactionBuilder::new("default", "onboard");
// Add key to signees
let signees = signees!(key);
// Build the transaction to a string
let tx = tx_builder
.input(input_data).unwrap()
.build(signees).unwrap();
// Create a transaction object and send
let tx = Transaction::new(tx);
connection.send_transaction(tx).unwrap();
}
require __DIR__ . '/vendor/autoload.php';
// Setup the connection object to use localhost over http unencrypted
$connection = new activeledger\sdk\Connection("http", "127.0.0.1", 5260, false);
// Generate Elliptic Key
$identity = activeledger\sdk\Key::generateKeyIdentity();
try {
// Onboard Key
$stream = $identity->onBoard($connection);
}catch(Exception $error) {
// Manage any exceptions such as consensus problem or transport errors
die($error->getMessage());
}
try {
// Onboard Key
$stream = $identity->onBoard($connection);
// Generate Activeledger Transaction
$transaction = activeledger\sdk\Transaction::build(
"0000482232bcca98e3f2b375e6209400e185fae26efad7812268d7d66b321131",
"example-namespace",
// Input Streams (Requires Signatures)
array($stream => array("text" => "Hello World"))
);
// Get signed version of this transaction
$signedTx = $identity->sign($transaction)
// Submit
$response = $connection->send($signedTx);
// Response object will contain the streams property.
$response->streams->new; // Contains created Activity Streams
$response->streams->updated; // Contains updated Activity Streams
}catch(Exception $error) {
// Manage any exceptions such as consensus problem or transport errors
die($error->getMessage());
}
// Generate a key
KeyGen keyGen = (KeyGen) ctx.getBean("KeyGen");
KeyPair keyPair = keyGen.generateKeyPair(Encryption.EC);
// Setup connection
ActiveledgerJavaSdkApplication.setConnection("protocol", "url", "port");
// Onboard key
onboardIdentity = (OnboardIdentity) ctx.getBean("OnboardIdentity");
JSONObject inJson = onboardIdentity.onboard(keyPair, Encryption.EC, "IdentityName");
// Send transaction
GenericTransaction genericTransaction = (GenericTransaction) ctx.getBean("GenericTransaction");
JSONObject genericTransactionOutput = genericTransaction.transaction(Transaction Object);
// Initialise the SDK
ActiveLedgerSDK.getInstance().initSDK(this,"protocol","URL","port");
// Generate KeyPair
KeyPair keyPair = ActiveLedgerSDK.getInstance().generateAndSetKeyPair(keyType,true);
// Onboard KeyPair
ActiveLedgerSDK.getInstance().onBoardKeys(KeyPair, "KeyName");
// Create a transaction
JSONObject jObj = ActiveLedgerSDK.getInstance().createBaseTransaction(JSONObject $tx, Boolean selfsign, JSONObject $sigs);
// Submit
ActiveLedgerSDK.getInstance().executeTransaction(String json);
using System;
namespace HelloWorld
{
class Hello
{
static void Main()
{
Console.WriteLine("Hello World!");
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}
from activeLedger-sdk import onboard, user
# Create onboard object and identity
user = onboard.createIdentity([‘identity name’])
# Generate key
user.generate_key([‘key type’], [‘key length’])
# Onboard key
user.setHTTP([‘activeledger server address:port’])
res = onboard.onboardIdentity(user)
# Assign the stream ID to the user object
user.setStreamID(res)
As legacy systems face the challenges of rapid technological growth, Activeledger is the premier solution for ensuring interoperability and transparency as enterprises look to adapt to the changing climates of the business world. Our distributed ledger technology also has a number of interesting and viable use case scenarios.
Here at Activeledger we put you first, solutions will be tailored to your specific needs and wants. Whatever the issue, our talented team of experienced developers and business advisors will be on-hand to provide their valuable input.
Active Harmony is a feature rich IDE built to work directly with Activeledger. Allowing for easy onboarding of keys, as well as managing the creation, upload, and running of contracts.