Skip to content

Terminal RPC API

Dowland Aiello edited this page Apr 17, 2019 · 5 revisions

Launching the Go-Summercash Terminal

On Launch:

go run main.go --terminal

After Launch (must have RPC API enabled):

go run main.go --terminal --rpc-address 127.0.0.1

Namespaces

Accounts

Creating a new Account:

accounts.NewAccount() // Returns account address and private key

Creating a new Contract Account:

accounts.NewContractAccount() // Returns account address and private key

Listing all Local Accounts:

accounts.GetAllAccounts() // Returns all account addresses separated by commas

Logging an Account's Contents:

accounts.String(0x040123456) // Replace with account address; returns account JSON value

Logging an Account's Hex Byte Value:

accounts.Bytes(0x040123456) // Replace with account address; returns account hex encoding (prefixed with 0x)

Crypto

Hashing via Sha3:

crypto.Sha3(despacito) // Returns hex-encoded sha3 hash of input (no 0x)

Hashing via Sha3d:

crypto.Sha3d(despacito) // Returns hex-encoded sha3d hash of input (no 0x)

Hashing via Sha3n:

crypto.Sha3n(despacito, n) // Replace n with num of repeated hashes; returns hex-encoded sha3n hash of input (no 0x)

Config

Creating a new Chain Config:

config.NewChainConfig("genesis.json") // Replace with genesis file path; returns JSON value of initialized config

Logging the Hex Byte Value of a Config:

config.Bytes() // Returns hex-encoded config byte value (has 0x)

Logging the JSON String Value of a Config:

config.String() // Returns JSON config string value

Obtaining the Total Circulating Supply From a Config:

config.GetTotalSupply() // Returns decimal total supply

Transactions

Creating a New Transaction:

transaction.NewTransaction(sender_address, recipient_address, amount) // Returns transaction hash

Signing a Transaction:

transaction.SignTransaction(0x040123456) // Replace with transaction hash; returns transaction signature JSON value

Publishing a Transaction:

transaction.Publish(0x040123456) // Replace with transaction hash; returns success/error message

Logging the JSON String Value of a Transaction:

transaction.String(0x040123456) // Replace with transaction hash; returns JSON tx string value

Verifying a Transaction's Signature:

transaction.VerifyTransactionSignature(0x040123456) // Replace with transaction hash; returns bool
Clone this wiki locally