Obyte devnet is a simplified and sped up version of the Obyte cryptocurrency network ideal for developing Autonomous Agents and bots. This tutorial focuses on setting up devnet on a local machine for developing Autonomous Agents
<p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmSwQCJbeKHfoeyfg87CnrPSmqfhKSuBynM1nKLxDxGZkf/obyte-devnet.png" alt="obyte-devnet.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmSwQCJbeKHfoeyfg87CnrPSmqfhKSuBynM1nKLxDxGZkf/obyte-devnet.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmSwQCJbeKHfoeyfg87CnrPSmqfhKSuBynM1nKLxDxGZkf/obyte-devnet.png 2x" /> <p dir="auto">Developing cryptocurrency applications and smart contracts is typically time consuming task due to the long confirmation times of transactions posted on testnets or mainnets. Obyte is among the fastest cryptocurrencies when it comes to the time required for global consensus, it's about 10 minutes at the time of writing this article, still when you have to develop a program that posts transactions on the ledger, waiting for confirmations every time you want to test a single transaction is really only for very very patient people. <h1>Obyte devnet <p dir="auto"><a href="https://github.com/pmiklos/obyte-devnet" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Obyte devnet started as a separate project but some of its concepts has been integrated into the Obyte core libraries since the addition of the Autonomous Agents. The main idea is to be able to run a complete Obyte network on a single development machine with fast confirmation times. To achieve that, the devnet has only one witness instead of 12 and one hub to which wallets can connect to. The witness posts every minute and since there is only one, it immediately makes earlier transaction stable. <p dir="auto">Let's jump right into it how to set it up. <p dir="auto">We are going to install the followings: <ul> <li>Obyte devnet <li>Oscript backend <li>Oscript frontend <li>Obyte devnet GUI wallet <p dir="auto">System requirements: <ul> <li>git - to fetch devnet and Oscript source code <li>npm - to run devnet <li>yarn - to run Oscript backend and frontend <li>Linux - the devnet init script is a simple bash script but it should be fairly easy to manually execute the steps on other operating systems. <li>docker - if you chose to run the GUI wallet in docker <h1>Installing devnet <p dir="auto">First get the source code and check out the <code>aa branch. The <code>aa branch contains the latest features for autonomous agent development. <pre><code>git clone https://github.com/pmiklos/obyte-devnet.git cd obyte-devnet git checkout aa <p dir="auto">Next, install and configure devnet. Start with fetching nodejs dependencies: <pre><code>npm install <p dir="auto">Then run the init script which copies the pre-generated configuration files for the devnet witness including the keys of the witness to make the devnet more predictable eg. the witness address and pairing code will always be the same. Next generate the genesis unit and the first asset, the blackbytes. Creating the blackbytes asset is optional, but it doesn't hurt to have it. <p dir="auto">The genesis and blackbytes steps ask for password, simply press an Enter. There is an empty password set for the devnet witness. <pre><code>npm run init npm run genesis npm run blackbytes <p dir="auto">At this point the devnet hub and witness are configured and ready to be launched. Start the hub: <pre><code>npm run hub <p dir="auto">Then open a new console and start the witness (press Enter when it asks for password): <pre><code>npm run witness <p dir="auto"><span>You can now open a browser and go to <a href="http://localhost:8080/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">http://localhost:8080/ to see the Obyte devnet DAG explorer. New units should be posted by the witness every minute. <h1>Installing Oscript editor <p dir="auto">Oscript editor is recommended to install if you work with Autonomous Agents since it makes authoring agents a lot easier by providing syntax highlighting and code completion, validation and deployment. <p dir="auto">Open another console and install the <a href="https://github.com/byteball/oscript-editor-backend" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Oscript backend <pre><code>git clone https://github.com/byteball/oscript-editor-backend.git cd oscript-editor-backend echo "devnet=1" > .env yarn install <p dir="auto">The <code>.env file configures the Oscript backend for devnet. You can start the Oscript backend with <pre><code>yarn start <p dir="auto">Now that the backend is running, let's install the <a href="https://github.com/byteball/oscript-editor" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Oscript frontend which will provide you with a web based editor to develop Autonomous Agents in Oscript language. <pre><code>git clone https://github.com/byteball/oscript-editor.git cd oscript-editor yarn <p dir="auto">Run the Oscript editor in development mode: <pre><code>yarn run serve <p dir="auto"><span>It is going to print the URL where the editor is available, but most likely it will be <a href="http://localhost:8081/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">http://localhost:8081/ if you have the devnet explorer already running on port 8080. <p dir="auto">At this point you are ready to develop Obyte Autonomous Agents and deploy them on your local devnet. <h1>Installing devnet GUI wallet the hard way <p dir="auto">So we have the whole Obyte infrastructure running on our laptops, but one thing is missing: the Obyte GUI wallet to access and use the devnet. You can build the testnet wallet from source by following the instructions on the <a href="https://github.com/byteball/obyte-gui-wallet" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">obyte-gui-wallet readme section. To build the wallet with Autonomous Agents support, you will have to use the <code>aa branch. <pre><code>git clone https://github.com/byteball/obyte-gui-wallet.git cd obyte-gui-wallet git checkout aa echo "devnet=1" > .env <p dir="auto">and then follow the steps in the readme. Tip: use the same NW.js and Nodejs versions as recommended in the guide to avoid unnecessary problems. <h1>Installing devnet GUI wallet the easy way <p dir="auto">If you are familiar with docker, there is an simpler way to run the devnet wallet. It has the advantage of easily creating as many throwaway wallets you need for testing. You can build your own image or simply download a prebuilt one from docker hub at <a href="https://cloud.docker.com/u/pmiklos/repository/docker/pmiklos/obyte-devnet-wallet" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">pmiklos/obyte-devnet-wallet. Let's use the prebuilt image: <pre><code>docker run -d --rm \ --name obyte-devnet-wallet \ --network=host \ -e DISPLAY=$DISPLAY \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -v obyte-devnet-wallet-data:/obyte \ pmiklos/obyte-devnet-wallet:2.7.2-aa <p dir="auto">That's it. The above command should launch the GUI wallet for the devnet. I recommend to create a script or a bash alias for the above command to make it easy to launch the devnet wallet. I, for example, use the following bash function to easily create new devnet wallets: <pre><code>function obyte-devnet-wallet() { local name="${1:-default}" docker run -d --rm --name obyte-devnet-wallet-$name --network=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v obyte-devnet-wallet-$name-data:/obyte pmiklos/obyte-devnet-wallet:2.7.2-aa } <p dir="auto">Then launching a devnet wallet is as simple as: <pre><code>obyte-devnet-wallet mylittlewallet <h1>Final tips <p dir="auto"><strong>Funding the GUI wallet<br /> In devnet, the witness holds all the funds initially. You can distribute those funds to any address by using the RPC interface of the witness exposed on port 6612: <pre><code>$ curl --data '{"jsonrpc":"2.0", "id":1, "method":"sendtoaddress", "params":["7AAUNXYL3G5RB73TKQPCPGC6FLRM2G6", 12345678] }' http://127.0.0.1:6612 <p dir="auto">See more info in <a href="https://github.com/pmiklos/obyte-devnet/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">obyte-devnet GitHub page (check the <code>aa branch for the latest development version). <p dir="auto"><strong>Start a clean state<br /> Occasionally you want to destroy the whole devnet state and start with a clean DAG. You can easily do that by removing the witness and hub configuration folders and re-running the initialization, genesis creation and blackbytes asset definition steps. On Linux, it would be (stop the witness and hub first): <pre><code>rm -rf ~/.config/obyte-devnet-* npm run init npm run genesis ...
Congratulations @pmiklos! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!