Factom-walletd serves the wallet API on port 8089. All these APIs use JSON-RPC, which is a remote procedure call protocol encoded in JSON. It is a very simple protocol (and very similar to XML-RPC), defining only a handful of data types and commands.
When adding entry credit outputs, the amount given is in factoshis, not entry credits. This means math is required to determine the correct amount of factoshis to pay to get X EC.
(ECRate * ECTotalOutput)
In our case, the rate is 1000, meaning 1000 entry credits per factoid. We added 10 entry credits, so we need 1,000 * 10 = 10,000 factoshis
You can find the entry credit rate with this API call.
add-fee
Example Request
curl -X POST --data-binary '{"jsonrpc":"2.0","id":0,"method":"add-fee","params":{"tx-name":"TX_NAME","address":"FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q"}}' \-H 'content-type:text/plain;' http://localhost:8089/v2
Addfee is a shortcut and safeguard for adding the required additional factoshis to covert the fee. The fee is displayed in the returned transaction after each step, but addfee should be used instead of manually adding the additional input. This will help to prevent overpaying.
Addfee will complain if your inputs and outputs do not match up. For example, in the steps above we added the inputs first. This was done intentionally to show a case of overpaying. Obviously, no one wants to overpay for a transaction, so addfee has returned an error and the message: ‘Inputs and outputs don’t add up’. This is because we have 2,000,000,000 factoshis as input and only 1,000,000,000 + 10,000 as output. Let’s correct the input by doing 'add-input’, and putting 1000010000 as the amount for the address. It will overwrite the previous input.
Curl to do that:
curl -X POST --data-binary '{"jsonrpc":"2.0","id":0,"method":"add-input","params": {"tx-name":"TX_NAME","address":"FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q","amount":1000010000}}' \ -H 'content-type:text/plain;' http://localhost:8089/v2
Run the addfee again, and the feepaid and feerequired will match up.
add-input
Example Request
curl -X POST --data-binary '{"jsonrpc":"2.0","id":0,"method":"add-input","params":{"tx-name":"TX_NAME","address":"FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q","amount":2000000000}}' \ -H 'content-type:text/plain;' http://localhost:8089/v2
Adds an input to the transaction from the given address. The public address is given, and the wallet must have the private key associated with the address to successfully sign the transaction.
The input is measured in factoshis, so to send ten factoids (10 FCT), you must input 1,000,000,000 factoshis (without commas in JSON)
add-output
Example Request
curl -X POST --data-binary '{"jsonrpc":"2.0","id":0,"method":"add-output","params":{"tx-name":"TX_NAME","address":"FA2H7gecy8Nr7cxF7ngtByW23PxvrysuzYMAiAhbRTddCWZTLs4P","amount":1000000000}}' \-H 'content-type:text/plain;' http://localhost:8089/v2
This method, compose-chain, will return the appropriate API calls to create a chain in factom. You must first call the commit-chain, then the reveal-chain API calls. To be safe, wait a few seconds after calling commit.
Ensure that all data given in the firstentry fields are encoded in hex. This includes the content section.
This method, compose-entry, will return the appropriate API calls to create an entry in factom. You must first call the commit-entry, then the reveal-entry API calls. To be safe, wait a few seconds after calling commit.
Ensure all data given in the entry fields are encoded in hex. This includes the content section.
compose-transaction
Example Request
curl -X POST --data-binary '{"jsonrpc":"2.0","id":0,"method":"compose-transaction","params":{"tx-name":"TX_NAME"}}' -H 'content-type:text/plain;' http://localhost:8089/v2
Compose transaction marshals the transaction into a hex encoded string. The string can be inputted into the factomd API factoid-submit to be sent to the network.
Import a Koinify crowd sale address into the wallet. In our examples we used the word “yellow” twelve times, note that in your case the master passphrase will be different.
This will create a new transaction. The txid is in flux until the final transaction is signed. Until then, it should not be used or recorded.
When dealing with transactions all factoids are represented in factoshis. 1 factoid is 1e8 factoshis, meaning you can never send anything less than 0 to a transaction (0.5).
When paying from a transaction, you can also make the receiving transaction pay for it. Using sub fee, you can use the receiving address in the parameters, and the fee will be deducted from their output amount.
This allows a wallet to send all it’s factoids, by making the input and output the remaining balance, then using sub fee on the output address.
This will retrieve a transaction by the given TxID. This call is the fastest way to retrieve a transaction, but it will not display the height of the transaction. If a height is in the response, it will be 0. To retrieve the height of a transaction, use the 'By Address’ method
This call in the backend actually pushes the request to factomd. For a more informative response, it is advised to use the factomd transaction method
The developers were so preoccupied with whether or not they could, they didn’t stop to think if they should.
The amount of data returned by this is so large, I couldn’t get you a sample output as it froze my terminal window. It is strongly recommended to use other techniques to retrieve transactions; it is rarely the case to require EVERY transaction in the blockchain. If you are still determined to retrieve EVERY transaction in the blockchain, use other techniques such as using the 'range’ method and specifically requesting for transactions between blocks X and Y, then incrementing your X’s and Y’s until you reach the latest block. This is much more manageable.
The wallet-balances API is used to query the acknowledged and saved balances for all addresses in the currently running factom-walletd. The saved balance is the last saved to the database and the acknowledged or “ack” balance is the balance after processing any in-flight transactions known to the Factom node responding to the API call. The factoid address balance will be returned in factoshis (a factoshi is 10^8 factoids) not factoids(FCT) and the entry credit balance will be returned in entry credits.
If walletd and factomd are not both running this call will not work.
If factomd is not loaded up all the way to last saved block it will return: “result”:{“Factomd Error”:“Factomd is not fully booted, please wait and try again.”}
If an address is not in the correct format the call will return: “result”:{“Factomd Error”:”There was an error decoding an address”}
If an address does not have a public and private address known to the wallet it will not be included in the balance.
"fctaccountbalances" are the total of all factoid account balances returned in factoshis.
"ecaccountbalances" are the total of all entry credit account balances returned in entry credits.