Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Determine lightweight SDK API calls #885

Open
ixje opened this issue Feb 13, 2019 · 4 comments
Open

Determine lightweight SDK API calls #885

ixje opened this issue Feb 13, 2019 · 4 comments

Comments

@ixje
Copy link
Member

ixje commented Feb 13, 2019

This is a TODO for a project (see side bar)

Create an inventory of useful/required API’s to interact with the blockchain without having to run a full node and propose a structure. The NeoModules structure/module separation has been indicated to be very useful by other users. Try to use that as a reference. For more ideas look at neon-js

The bare minimum functionality to support:

  • Support asset (NEO/GAS) transfers
  • Support GAS claiming
  • Support NEP-5 transfers and information querying
  • Support offline signing
  • Support multi-signature wallets

For RPC functionality keep #884 in mind

@lock9
Copy link

lock9 commented Mar 6, 2019

Hello, I did some research on this subject. Based on what we have in neon-wallet, neon-js and neo-modules, we need to implement these features if we want a complete light-weight SDK:

Transaction support:

  • Contract
  • Claim
  • Invocation

Transaction building:

  • Claim gas
  • Send native asset
    • Send
    • SendMany
    • Split
  • Call contract with attachments
  • Deploy smart contract
  • NEP-5
    • Send
    • SendMany
  • Custom ('raw transaction')

API integration:

  • Neo RPC
  • NeoScan
  • NeoTracker
  • NEL
  • Notification Server
  • CoZ Monitor

Wallet features:

  • NEP 2
  • NEP 6
  • Signing
  • Multisigning

Other:

  • Node selection policy
  • Network selection (main/testnet/custom)
  • Transaction tracking
  • Authentication headers

@ixje
Copy link
Member Author

ixje commented Mar 6, 2019

Nicely done @lock9! Can you elaborate a bit more on:

  • API integration with NEL.
    What API do they have? any links
  • API integration with CoZ monitor.
    Does that have an API? any link to the description/endpoints?
  • Node selection policy
    I'm guessing you mean RPC node selection? Any example policies you have in mind?
  • Transaction tracking
    Can you elaborate what this would do? what exactly are we tracking? That the TX is accepted on the network or something else?
  • Authentication headers
    I have no idea what this would touch on. First thing that comes to mind is BasicHTTP authentication but I have no idea for which services that is required in the SDK

@lock9
Copy link

lock9 commented Mar 6, 2019

Hello

  • API integration with NEL.
    What API do they have? any links

https://scan.nel.group/
(docs here: http://www.xiaoyaoji.cn/share/1H0gjTDtfk/)

  • API integration with CoZ monitor.
    Does that have an API? any link to the description/endpoints?

http://monitor.cityofzion.io/assets/testnet.json
http://monitor.cityofzion.io/assets/mainnet.json

  • Node selection policy
    I'm guessing you mean RPC node selection? Any example policies you have in mind?

Yes. Here is an example from neon-wallet: https://github.com/CityOfZion/neon-wallet/blob/dev/app/actions/nodeStorageActions.js

  • Transaction tracking
    Can you elaborate what this would do? what exactly are we tracking? That the TX is accepted on the network or something else?

Exactly. After we send the transaction using sendrawtransaction we need to track it's result. We also may need to track if it's still waiting in the memory pool.

  • Authentication headers
    I have no idea what this would touch on. First thing that comes to mind is BasicHTTP authentication but I have no idea for which services that is required in the SDK

I think this is required if you are hosting a private RPC server and you want to allow only certain users to interact with it

@ixje ixje moved this from To do to In progress in Lightweight SDK API Mar 6, 2019
@lock9
Copy link

lock9 commented Mar 10, 2019

Going further:

Transaction building:
Claim gas

claimGas
(
address : String
)  -> String (TXId)

Send native asset

sendNativeAsset
(
fromAddr: String, 
changeAddr: String = fromAddr, 
attributes : List<TransactionAttribute>, 
value : Fixed8,
assetId : String,
fee : Fixed8 = Fixed8.Zero()
) -> String(TXId)

Send

SendMany

sendManyNativeAsset
(
fromAddr: String, 
changeAddr: String = fromAddr, 
attributes : List<TransactionAttribute>, 
outputs: List<TransactionOutput>,
fee : Fixed8 = Fixed8.Zero()
) -> String(TXId)

Split

split
(
fromAddr: String, 
attributes : List<TransactionAttribute>, 
value : Fixed8,
numberOfTransactions : int
fee : Fixed8 = Fixed8.Zero()
) -> String(TXId)

Call contract with attachments

callContract
(
fromAddr: String, 
contractScriptHash: string, 
attributes : List<TransactionAttribute>, 
attachments: List<TransactionOutput> = null,
fee : Fixed8 = Fixed8.Zero()
) -> String(TXId)

New - Test invoke.
This call requires further investigation (I'm not sure about the parameters)

testCallContract
(
fromAddr: String, 
contractScriptHash: string, 
attributes : List<TransactionAttribute>
) -> InvokeResult

Deploy smart contract

deployContract
(
fromAddr: String, 
contractScript : byte[],
parameterList : byte[],
returnType : ContractParameterType,
contractProperties :  ContractPropertyState,
authorName : String,
contractVersion : String,
authorEmail : String,
contractDescription : String
) -> String(TXId)

NEP-5
Send

sendNep5Asset
(
fromAddr: String, 
attributes : List<TransactionAttribute>, 
value : Fixed8,
assetId : String,
fee : Fixed8 = Fixed8.Zero()
) -> String(TXId)

SendMany

sendManyNep5
(
fromAddr: String, 
changeAddr: String = fromAddr, 
attributes : List<TransactionAttribute>, 
outputs: List<TransferOutput>,
fee : Fixed8 = Fixed8.Zero()
) -> String(TXId)

Custom ('raw transaction')
#886

API integration:

Neo RPC (2.9.0+)
https://docs.neo.org/en-us/node/cli/latest-version/api.html

dumpprivkey
getaccountstate
getassetstate
getbalance
getbestblockhash
getblock
getblock
getblockcount
getblockhash
getblockheader
getblocksysfee
getconnectioncount
getcontractstate
getnewaddress
getrawmempool
getrawtransaction
getstorage
gettxout
getpeers
getvalidators
getversion
getwalletheight
invoke
invokefunction
invokescript
listaddress
sendfrom
sendrawtransaction
sendtoaddress
sendmany
validateaddress

NeoScan
https://neoscan.io/docs/index.html

get_address_abstracts
get_address_to_address_abstracts
get_all_nodes
get_balance
get_block
get_claimable
get_claimed
get_height
get_last_transactions_by_address
get_transaction
get_unclaimed

NeoTracker

NEL
http://www.xiaoyaoji.cn/share/1H0gjTDtfk/1dLQ8CDVdd

 getnodetype
 getcliblockcount
 getcliversion
 getclirawmempool
 getblockcount
 getdatablockheight
 getblock
 getrawtransaction
 getasset
 getfulllog
 getnotify
 getutxo
 getutxocount
 getutxostopay
 getbalance
 getblocks
 getrawtransactions
 gettxcount
 getcontractscript
 setcontractscript
 getaddrcount
 getaddrs
 getaddr
 getallasset
 gettransfertxhex
 sendtxplussign
 sendrawtransaction
 getaddresstxs
 getcontractstate
 invokescript
 callcontractfortest
 getinvoketxhex
 getclaimgas
 getclaimtxhex
 getstorage
 getallnep5assetofaddress
 getnep5transfersbyasset
 getnep5balanceofaddress
 getnep5asset
 getallnep5asset
 getnep5transferbytxid
 getnep5transferbyaddress
 getnep5transfers
 getaddresstxbyblockindex
 getnep5transferbyblockindex
 getnep5count
 getclaimgasUtxoList

Notification Server
http://notifications1.neeeo.org/

/v1/notifications/block/<height>
notifications by block
/v1/notifications/addr/<addr>
notifications by address
/v1/notifications/tx/<hash>
notifications by tx
/v1/notifications/contract/<hash>
notifications by contract
/v1/tokens
lists all NEP5 Tokens
/v1/token/<contract_hash>
list an NEP5 Token
/v1/status
current block height and version

CoZ Monitor

http://monitor.cityofzion.io/assets/testnet.json
http://monitor.cityofzion.io/assets/mainnet.json

Wallet features:
NEP 2

encrypt
(
wif : String, 
password : String,
scryptParameters : ScryptParameters = ScryptParameters.Default
) -> Void

decrypt
(
nep2 : String,
password : String,
scryptParameters : ScryptParameters = ScryptParameters.Default
) -> String(wif)

NEP 6 - Account

setLabel(name : String) -> Void
getLabel() -> String
getAddress() -> String
isDefaultAccount() -> Boolean
setDefaultAccount(setDefault : Boolean) : Void
isLocked() -> Boolean
setLocked(locked : Boolean) -> Void
setNep2Key(nep2Key : String) -> Void
getNep2Key() -> String
setContract(contract : Contract) -> Void
getContract() -> Void
setExtra(extra : Object) -> Void
getExtra() -> Object
toJson() -> String
fromJson(json : String) -> Account

NEP 6 - Wallet

setName(name : String) -> Void
getName() -> String
getVersion() -> String
setScryptParameters(scryptParameters = scryptParameters) -> Void
getAccounts() -> List<Account>
setExtra(extra : Object)
getExtra() -> Object
addAccount(account : Account) -> Void
removeAccount(address : String) -> Boolean
setDefaultAccount(account: Account) -> Boolean
lockAccount(address : String) -> Boolean
unlockAccount(address : String) -> Boolean
toJson() -> String
fromJson(json : String) -> Wallet
saveToPath(path : String) -> Void
loadFromPath(path : String) -> Wallet

Signing

signMessage(hexMessage : String) -> String (hexSignature)
signTransaction(transaction : Transaction) -> byte[]

Multisigning
(I'm not sure about this)

getSignatures(transaction : Transaction) -> Witness[]
addSignature(transaction : Transaction, signature : byte[])

Other:
Node selection policy
Network selection (main/testnet/custom)
Transaction tracking
Authentication headers

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Lightweight SDK API
  
In progress
Development

No branches or pull requests

2 participants