Hello colleagues!
My purpose is to save some data X inside the blockchain and then read and “change” it.
Could someone explain what is technically mean if I send ‘data’ transaction more that once:
const { data } = require(‘waves-transactions’)
const signedDataTx = data(previousSignedDataTx)
Can I use this way to save my data inside the blockchain and then ‘change’ it multiple times?
Can I see the data transaction history for corresponding account?
Basically Data transaction is a key-value update for the data storage of the account. The first data transaction creates a key-value storage attached to the account and puts its keys and values in this storage. The following data transactions will update values of existing keys or add new key-value pairs to the account’s storage.
Removing of the key is not possible using the data transaction. The only way is to set the empty value to the key.
So, yes, you can add and update the key-value storage in blockchain.
All transactions are stored in blockchain, so the full history of data updates always here. Maybe there is no API for this. But you always can fetch all transactions for the account.
I don’t know exactly how JS library works, but maybe you haven’t send the transaction to the node?
Alexey, thank you for detailed explanation:+1:
Concerning testnet, I do not fully understand what I must set to send transactions into testnet and where I can see them.
I just set network byte as I described above,
I suppose I do not set some urls. If you describe how it works I will be very grateful.
I’m writing JS code and want to easy change network (main/test) and view transactions inside both.
To create the transaction you have to do following steps:
Create a transaction object of desired type
Sign the transaction
Broadcast the transaction to the network using the node’s API method POST transactions/broadcast
The networkByte affects some transactions and the address generation from public keys.
To sign a transaction use the correct private key, the key that was used to generate your address.
To broadcast transaction simply post it’s JSON to any public node.
Alexey, thank you,
I want to use JS libs instead of REST API, looks like I need someone, who knows how we can solve typical tasks (which are solvable using old library) with the new libraries for JavaScript.
Looks like I should set node URL and matcher URL?
The networkByte affects some transactions and the address generation from public keys.
My mistake is that I thought that inside the new libraries this flag chooses network:(
So, despite everything, I cannot find how to set network config for new libraries as it easy can be set for not maintained waves-api.
Added:
After some additional help from Discord group I’ve understood that new libraries like waves-transactions are local and do not require network configuration and for each transaction I have to call REST “transactions/broadcast” end-point.
It is really as easy as unclear:-) Please add some words to docs for people like me)
@alexey.kiselev Alexey, how can I get latest=current storage state (after a lot of data transaction, which change some values separately)?
So, my task is change state multiple times then read it to make some calculations off-chain.
Use API methods addresses/data/{address} and addresses/data/{address}/{key}. The first one will return the complete account data state, the latter only the current value of the key.
Guys from the client dev team told me that in this case “sent” or “отправленные” means tokens sent out from your wallet. So, here you will see only outgoing transfer transactions. Data transactions should appear only on “All” page.