You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: deso-features/associations.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# 1⃣ Associations
1
+
# 1️⃣ Associations
2
2
3
3
A social network can be visualized as an undirected graph with users and posts acting as nodes and their interactions acting as the edges connecting them.
4
4
@@ -16,7 +16,7 @@ And in total, we've introduced **4 new distinct transaction types** on the DeSo
16
16
*_CREATE\_POST\_ASSOCIATION_
17
17
*_DELETE\_POST\_ASSOCIATION_
18
18
19
-
A simple way to think of this relationship is that 1) user associations connect a user (_the transactor_) to another user (_the target user_), and 2) post associations connect a user (_the transactor_) to a post (_the target pos_t).
19
+
A simple way to think of this relationship is that 1) user associations connect a user (_the transactor_) to another user (_the target user_), and 2) post associations connect a user (_the transactor_) to a post (_the target pos_t).
20
20
21
21
In addition to the transactor and the target user or post, associations have three customizable fields:
If you chose to clone and attach all of the suggested repos (besides MegaSwap), **you actually have 100% of the code powering the DeSo blockchain sitting on your computer right now.**
105
89
@@ -121,7 +105,7 @@ For this, there are a couple of other tutorials that you may find interesting:
121
105
122
106
* For most people, it is sufficient to simply use another node such as [node.deso.org](http://node.deso.org) to construct transactions and query.\
123
107
\
124
-
_**BUT**_ if you’d like to run your own node, and download all of DeSo’s user data, including all profiles, posts, and follows from the beginning of time, then the above guide will show you how.\
108
+
&#xNAN;_**BUT**_ if you’d like to run your own node, and download all of DeSo’s user data, including all profiles, posts, and follows from the beginning of time, then the above guide will show you how.\
125
109
126
110
* It will also show you how to build and curate your own feed, if you want.
127
111
@@ -165,15 +149,7 @@ To get the example app up and running, simply follow the steps from the README o
165
149
166
150
Once you’re done, you should be able to visit [localhost:3000](http://localhost:3000) in an Incognito tab and see the following. We recommend you load it up in Incognito to avoid cluttering your main wallet:
* Now, send 0.00001 $DESO from your main account to the test account. It’s only about a hundredth of a penny, and your app will make much more than that when it’s successful don’t worry :)
234
194
* Also, note that it says that you need to send 0.01 $DESO. Ignore that — you can get away with much less.\
@@ -255,15 +215,7 @@ We won’t go into it just yet, but it will be a key way in which users move fun
255
215
256
216
To see examples of MegaSwap in action, check it out at [megaswap.xyz](https://megaswap.xyz), [Diamond](https://diamondapp.com/buy-deso), and [Openfund](https://openfund.com/wallet). Note that Diamond does a one-line [embed](https://megaswap.xyz/#/iframe/docs/v1) while Openfund uses the API documented [here](https://megaswap.xyz/#/api/docs/v1).
The Openfund platform is essentially a frontend client over the DeSo DEX, which powers its order-book functionality. As such, placing and managing orders on Openfund amounts to constructing and submitting transactions to the DeSo blockchain, which can be done totally permission-lessly, just like submitting a transaction to the Bitcoin network. In this section, we go over how to construct and submit transactions, and walk through the creation of a simple market-making bot.
First, if you’re going to be writing a trading bot, it is best to familiarize yourself with the DeSo node testnet UI, node [accessible here](https://test.deso.org/), and the Openfund testnet UI, [accessible here](https://dev.openfund.com/trade). This will allow you to do everything with “fake money” so that you don’t put capital at risk until you’re sure everything is working properly.
4
+
5
+
To set up a testnet account, simply execute the following steps:
1. This is the reference node for testnet that most developers get started on when testing. Note that anyone can run a DeSo node by following the instructions in [the core repo](https://github.com/deso-protocol/core), this just happens to be a fairly reliable one.
9
+
2. Create an account
10
+
1. Note that DeSo wallets are managed locally in your browser. The DeSo wallet works almost exactly like MetaMask, only it doesn’t require the installation of a Chrome extension, and it supports much more granular and transparent permissions at an app level. This means that creating a wallet on one app results in that wallet being accessible to any other DeSo app as long as permissions are confirmed, including [Openfund](https://openfund.com), [Diamond](https://diamondapp.com), and [Focus](https://focus.xyz) (noting these are mainnet links, not testnet ones, so your testnet wallet won’t be accessible there).
11
+
1. Note that when you use an app, a “derived key” is issued that has much more limited permissions than your master key, which you have to accept before using the app. This allows you to use an app without having to hit “confirm” on low-value transactions (e.g. making posts or liking posts) while being 100% sure the app can’t steal funds.
12
+
2. We recommend always using seed phrases for test accounts, as that tends to be easier to manage. You can use one seed phrase and create new accounts with different indexes by hitting “add account” in the wallet.
13
+
3. When creating an account you can enter your phone number to get 1 free testnet $DESO from the faucet
14
+
1. Note that testnet $DESO does not have any value outside of the test environment!
15
+
2. If you don’t want to enter your phone number, some apps use the advanced captcha flow, such as [dev.openfund.com](http://dev.openfund.com). Eventually this flow will be integrated back into the reference node.
16
+
4. Once you have an account with starter DESO, you can visit the following links to test things:
1. Here, you can place orders and use the inspector to see what transactions are being constructed and submitted to the DeSo blockchain.
21
+
22
+
For a reference on all useful testnet links, including the testnet block explorer, [see here](https://docs.deso.org/deso-validators/run-a-validator#h.gcb427f1q4hl).
23
+
24
+
For tips on creating lots of **mainnet** accounts with starter DESO in them, [see here](https://docs.deso.org/deso-tutorial-build-apps#tip-for-creating-lots-of-test-accounts).
25
+
26
+
For a primer on building DeSo apps, [see here](https://docs.deso.org/deso-applications). Useful as a reference, or if you find something confusing in this guide.
The DeSo blockchain is written in the Go programming language for high performance, and its code is 100% open-source, with the [core](https://www.github.com/deso-protocol/core) and [backend](https://github.com/deso-protocol/backend) repos being the most important for understanding the node architecture and transaction construction respectively. The core repo represents all of the most critical code for processing transactions, while the backend repo mostly consists of REST endpoints that you can call to construct and submit transactions. If you’re curious about them, it is useful to load both repos into your IDE to explore them (we recommend VSCode or Goland; our team uses both). This being said, even though the DeSo blockchain is written in Go, you don’t have to know Go in order to construct and submit transactions! In this section, we show you how use a simple Python library to construct, sign, and submit all of the basic order management transactions you’ll need in order to write a trading bot.
4
+
5
+
The Openfund client constructs, signs, and submits the exact same transactions you’ll be working with in this tutorial ([mainnet client](http://openfund.com/trade), [testnet client](https://test.deso.org/)). This means that, if you’re ever unsure of how to do something, you can simply open up the Openfund trade page, open up the inspector, go to the network tab, and look at how Openfund is constructing and submitting the transaction (lookup a tutorial on how to use the web inspector to do this if you’re not familiar with this kind of thing). The only thing you will not be able to get from this process is the signing of the transaction, which we’ll cover in this tutorial, and which the Python library already implements for you. In addition to using Openfund to inspect things, you can also use the reference DeSo node ([mainnet node](https://node.deso.org/), [testnet node](https://test.deso.org/browse?feedTab=Global)), which supports an even larger set of transactions, including making on-chain posts, following users on-chain, and much more. When Focus launches, you’ll have even more transaction types to explore there as well ([focus mainnet](http://focus.xyz), [focus testnet](http://beta.focus.xyz)). Often, when the core team adds new transaction types, they are tested on the reference DeSo nodes first, and so those are often the most “complete” places to see how transactions work. For the purposes of this tutorial, you can see how tokens are minted, burned, and sent on the “DAO” tab of the reference client, for example. For all trading transactions, though, Openfund is the best place to inspect them.
6
+
7
+
In addition, if you want to be more “hard-core,” you can read the DeSo node code itself to see how the transaction you’re trying to construct actually gets processed under-the-hood. All endpoints supported by the reference backend have a variable of the form RoutePath\*, such as [RoutePathUpdateProfile](https://github.com/deso-protocol/backend/blob/8a00fd811dd2faae78f9363b4efe7fc29d3617a6/routes/server.go#L55). If you look for usages, you will find them link dot the RoutePath with a format [like this](https://github.com/deso-protocol/backend/blob/8a00fd811dd2faae78f9363b4efe7fc29d3617a6/routes/server.go#L783). This allows you to trace what an endpoint is doing (useful if you get a weird error). The DeSo open-source node code also provides Go functions responsible for constructing transactions, all of which follow the general naming scheme Create\*Txn, such as [CreateUpdateProfileTxn](https://github.com/deso-protocol/core/blob/877178a9713604e8223ff33395ff15b62f2a2bb7/lib/blockchain.go#L3661), and you will generally see one of these functions if you trace a RoutePath for a txn construction endpoint. Every transaction type supported by the DeSo blockchain implements a \_connect function, such as [\_connectUpdateProfile](https://github.com/deso-protocol/core/blob/877178a9713604e8223ff33395ff15b62f2a2bb7/lib/block_view.go#L1973), which is what is called when a node on the network actually processes your particular transaction. To see all of the transaction types supported by the DeSo blockchain, you can simply search for all of the \_connect functions in [the core repo](https://github.com/search?q=repo%3Adeso-protocol%2Fcore+_connect\&type=code), and then find the Create function that calls it to see how it’s constructed as well (which could be in the [backend repo](https://github.com/deso-protocol/backend)). While this isn’t strictly necessary information, it can be useful if you are unsure why your transaction is being rejected by the network, or if you want to see what parameters you can provide to a particular transaction type. The best way to debug is to find the \_connect\* function that you’re trying to trigger, and then trace it up to the function that actually constructs the transaction to see what it’s doing. In addition, if you ever get an error, you can always find it in the core+backend repo if you have them loaded in your IDE. So, to summarize:
8
+
9
+
* To see all the possible endpoints you can hit to construct transactions or get data, look for RoutePath\* in the core+backend repos.
10
+
* Find the function that gets called and trace it to see how a transaction is constructed or how data is returned.
11
+
* To see all the txn types a node can process, look for all the \_connect functions in core and read through them, or find the one for your particular transaction type.
12
+
* Create\*Txn functions are responsible for constructing transactions, and are typically called in txn construction endpoints. You will likely trace through them if you get a weird error.
13
+
14
+
The transactions we’ll be most concerned with for trading are as follows (for legacy reasons, DeSo Tokens are referred to in the code as “DAO Coins”:
15
+
16
+
*\_connectDaoCoin
17
+
* Used to mint and burn your token, or to change transfer restrictions
18
+
*\_connectDaoCoinLimitOrder
19
+
* Used to create market and limit orders, and to cancel orders
20
+
*\_connectDaoCoinTransfer
21
+
* Used to transfer your token to other accounts
22
+
* We won’t cover them here, but you may also be interested in the following functions, which allow you to add yield to your coin:
23
+
*\_connectCoinLockup
24
+
*\_connectCoinLockupTransfer
25
+
*\_connectUpdateCoinLockupParams
26
+
27
+
If you want, you can trace how the above functions are called all the way to the RoutePath, which will then tell you how to actually trigger them with a simple HTTP request. But it’s easier to instead inspect http requests on an existing app, like Openfund, and work “top-down” from the RoutePath, so that’s what we generally recommend. We just want to give you both options so you have the maximum ability to debug.
28
+
29
+
Whenever you’re constructing a transaction, as the next section will show you how to do, you may get a really long and hard to read error message. The key to deciphering these is to go all the way to the end and look for the RuleError that you got. For example, frequently you will have RuleErrorInsufficientBalance if you have no DESO or something like that. The RuleError should always tell you what’s going on, and be self-explanatory. But if it’s not, then you can go into the code as mentioned above and trace what’s going on. Thus is the benefit of 100% open-source software!
Everything you need to construct, sign, and submit transactions is in [the DeSo Python SDK](https://github.com/deso-protocol/deso-python-sdk). This is an advanced library that makes it extremely easy to do all of DeSo’s basic (and not-so-basic) transaction types.
4
+
5
+
The best way to learn is to simply go through the README and run the code. Once you’ve gotten everything to a “SUCCESS” status, you can proceed to the challenges, which simultaneously walk you through how to build an advanced market-making bot, as well as advanced social bots.
0 commit comments