<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[0xcert - Medium]]></title>
        <description><![CDATA[Your ID, degree, artwork or house. 0xcert-ified on the blockchain. - Medium]]></description>
        <link>https://medium.com/0xcert?source=rss----30621f84231e---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>0xcert - Medium</title>
            <link>https://medium.com/0xcert?source=rss----30621f84231e---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 12:48:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/0xcert" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Testing smart contracts live without spending gas]]></title>
            <link>https://medium.com/0xcert/testing-smart-contracts-live-without-spending-gas-19920a55d65b?source=rss----30621f84231e---4</link>
            <guid isPermaLink="false">https://medium.com/p/19920a55d65b</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contract-blockchain]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[0xcert]]></dc:creator>
            <pubDate>Mon, 14 Oct 2019 10:14:05 GMT</pubDate>
            <atom:updated>2019-10-14T10:14:05.010Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*s-841mSPUw3BcMa4Kh747w.jpeg" /></figure><p><em>0xcert is publishing a series of tech papers in collaboration with various authors. The present article is a contribution by our advisor and the lead author of ERC-721 standard, </em><a href="https://github.com/fulldecent"><em>William Entriken</em></a><em>, and our lead blockchain engineer, </em><a href="https://github.com/MoMannn"><em>Tadej Vengust</em></a><em>. Written by: William Entriken, Tadej Vengust</em></p><p>In this article, we will introduce a technique that allows you to test <strong>any deployed contract</strong> in arbitrary ways, <strong>without spending gas</strong>. It works on Ethereum Mainnet, Wanchain, Ethereum Ropsten, Hyperledger Burrow, Proof of Authority Network, private chains, and every other network based on Ethereum Virtual Machine.</p><p><strong>This new technique was first shown with the </strong><a href="https://erc721validator.org/"><strong>ERC-721 Validator</strong></a><strong>, and you can’t do it with Truffle.</strong></p><p>You will want to learn this technique if:</p><ul><li>Your contract deployment is too complicated to use Truffle</li><li>You are testing somebody else’s contract, possibly without access to the source code</li><li>You want to batch test deployed contracts, and you don’t care how they were deployed</li><li>You are interested in weird stuff and errors in the Ethereum Yellow Paper</li></ul><p>Note that all Solidity examples used in this article are written in a way they can be copy-pasted and compiled with <a href="https://remix.ethereum.org/#optimize=false">Remix</a>. Page example uses Web3 and requires MetaMask.</p><h3>Clean Room Testing vs. Live Testing</h3><p>Most professional smart contract developers will prefer the cleanroom testing methodology. It is cheap (doesn’t spend gas), fast (doesn’t wait for transactions), and it makes reproducible results. In combination with Ganache (personal blockchain), Truffle is the best-known tool for this approach:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Rw_e8Zz5vY_Ldk2L.jpg" /></figure><p>Several situations could frustrate your ability to use this technique. For example, your contract may need live test data (not reproducible) to confirm that specific code paths work correctly. Or your deployment process may be too complicated to use Truffle. Or you want to test compatibility with a contract with no source code available. Or more simply, maybe your CEO had you deploy before test cases were finished.</p><p>A new methodology, <strong>live testing</strong>, allows you to perform validation tests on contracts on Mainnet while also having access to all Mainnet data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*xGqZJuVc6SxC1aPY.jpg" /></figure><p>Of course, it is also possible to deploy your stubs to Mainnet. However, this may be unnecessarily expensive and slow. Also note that in this setup, the validation process has full access to all Mainnet contracts and data.</p><h3>Testing With a Deployed Contract</h3><p>The live testing technique could be performed by deploying a smart contract written explicitly for testing to Mainnet and then calling that contract. Our first example will test whether or not Su Squares (an ERC-721 contract) has a total supply of 10,000 tokens. ( <a href="https://etherscan.io/address/0xE9e3F9cfc1A64DFca53614a0182CFAD56c10624F#code">Su Squares</a> was deployed with, and is intended to always have, precisely 10,000 non-fungible tokens).</p><p>Please note that the 10,000 tokens supply test was chosen for its simplicity to demonstrate the technique. The same technique can be used on much more complex tests.</p><pre>pragma solidity 0.5.6; <br>import &quot;https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/erc721-enumerable.sol&quot;; <br>contract SuSquaresTests <br>{  <br> ERC721Enumerable testSubject;   <br> <em>/**    <br>  * @notice Deploy test contract with a subject to be used for all tests.    <br>  */</em>   <br> constructor(     <br>  address _testSubject  <br> )    <br>  public  <br> {    <br>  testSubject = ERC721Enumerable(_testSubject); <br> }   <br> <em>/**   <br>  * @notice Test token supply invariant.  <br>  */</em>   <br> function testIsTotalSupply10000()    <br>  external    <br>  view   <br>  returns (bool testResult)  <br> {    <br>  testResult = testSubject.totalSupply() == 10000;<br> } <br>}</pre><p>This contract is already deployed on Mainnet, and you can play with it at <a href="https://etherscan.io/address/0x37d3bffed6f784d2cb5542bb9d9007c16e5938df">0x37d3bffed6f784d2cb5542bb9d9007c16e5938df</a>.</p><p>For some good reason, this test performs actions that require changing Mainnet state. Therefore, this test is expensive to deploy and costly to run. Also, it takes time to execute (due to one-block confirmation). Next, we will remove one of these expenses.</p><h3>Tests With ESTIMATEGAS</h3><p>We can remove the cost of executing this test function by using a built-in feature of the standard Ethereum client JSON-RPC (and by extension Web3.js), namely the <strong>ESTIMATEGAS</strong>. In the diagram below, “Client” refers to a Geth/Parity console session, Truffle or a web browser using web3.js.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*7SbU5f2nt3o6YnAx.jpg" /></figure><p>The parameters to <a href="https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_estimategas"><strong>estimateGas</strong></a> are equivalent to making a normal transaction except that you do not need to sign it and it returns the amount of gas used. (It is also possible to have a false/failed test result if all gas is used). In simple terms, <strong>estimateGas</strong> does everything exactly the same as making a transaction, but instead of committing the transaction it tells us how much the transaction would cost us.</p><p>You should also note that in the case of running <strong>estimateGas</strong> on a transaction that reverts (fails), the returned gas amount will be equal to the total gas available in a block.</p><p>With this in mind, we can modify the above test case so that the test result is expressed by the amount of gas used:</p><pre><em>/**   <br>  * @notice Test token supply invariant.   <br>  */</em> <br>function testIsTotalSupply10000()   <br>  external <br>{   <br>  require(testSubject.totalSupply() == 10000); <br>}</pre><p>In this new version, if the test fails, the gas spent will be the total gas available.</p><p>Now we have a way to run arbitrary test cases without having to pay each time we use them. In the next section, we will also remove the expense of deploying the contract. But to proceed, we must violate a statement from the Ethereum Yellow Paper.</p><h3>The Singleton Transaction Pattern</h3><p>The current version of the Ethereum Yellow Paper (the specification which all Ethereum clients should follow) states:</p><blockquote>There are [only] two types of transactions: those which result in message calls and those which result in the creation of new accounts with associated code (known informally as “contract creation”).</blockquote><p>This is actually incorrect since the Ethereum reference implementations we have checked — Geth and Parity and all other implementations we know — all allow a third type of transaction. We will abuse this fact in order to refactor the test contract and immediately perform a test case and return results — without having to actually deploy the contract. How? By moving the test case into the constructor.</p><pre>pragma solidity 0.5.6; <br>import “https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/erc721-enumerable.sol&quot;; <br>contract SuSquaresTests <br>{ <br>  <em>/** <br>   * @notice Deploy test contract with a subject to be used for all tests. <br>   */</em> <br>  constructor( <br>    ERC721Enumerable _testSubject<br> ) <br>  public <br> { <br>  testIsTotalSupply10000(_testSubject);<br>}<br>  <em>/**<br>   * @notice Test token supply invariant.<br>   */<br>  </em>function testIsTotalSupply10000( <br>    ERC721Enumerable _testSubject<br>  ) <br>    public <br>  { <br>    require(_testSubject.totalSupply() == 10000);<br>  } <br>}</pre><p>This example has violated the Ethereum Yellow Paper specification because here a transaction that created a contract has also made a message call into that contract. One call can also create multiple contracts and make multiple message calls into those contracts as will be shown in the stubs example later.</p><p>You must compile this contract to bytecode, first. Here is how to achieve this with Remix IDE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*3shpuTkuLM_Wbs71.gif" /></figure><pre>&lt;html&gt; <br>&lt;head&gt;   <br> &lt;title&gt;Estimate gas tests&lt;/title&gt; <br>&lt;/head&gt; <br>&lt;body&gt;   <br> &lt;script src=&quot;https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.0.0-beta.34/dist/web3.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;  <br> &lt;script&gt;     <br>  if (typeof window.web3 !== &quot;undefined&quot; &amp;&amp; typeof window.web3.currentProvider !== &quot;undefined&quot;) {<br>   var web3 = new Web3(window.web3.currentProvider);     <br>  } else {<br>    alert(&quot;No web3&quot;);   <br>  }   <br>  const abi = [    <br>   {     <br>    &quot;constant&quot;: false,      <br>    &quot;inputs&quot;: [     <br>     {        <br>      &quot;name&quot;: &quot;_testSubject&quot;,          <br>      &quot;type&quot;: &quot;address&quot;   <br>     }   <br>    ],   <br>    &quot;name&quot;: &quot;testIsTotalSupply10000&quot;,      <br>    &quot;outputs&quot;: [],    <br>    &quot;payable&quot;: false,       <br>    &quot;stateMutability&quot;: &quot;nonpayable&quot;,     <br>    &quot;type&quot;: &quot;function&quot;     <br>   }, <br>   {    <br>    &quot;inputs&quot;: [  <br>     {  <br>      &quot;name&quot;: &quot;_testSubject&quot;, <br>      &quot;type&quot;: &quot;address&quot;   <br>     }     <br>    ],     <br>    &quot;payable&quot;: false,    <br>    &quot;stateMutability&quot;: &quot;nonpayable&quot;,   <br>    &quot;type&quot;: &quot;constructor&quot;    <br>   }   <br>  ];   <br>  const bytecode = &quot;0x608060405234801561001057600080fd5b5060405160208061021d8339810180604052602081101561003057600080fd5b81019080805190602001909291905050506100508161005660201b60201c565b506100e7565b6127108173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561009f57600080fd5b505afa1580156100b3573d6000803e3d6000fd5b505050506040513d60208110156100c957600080fd5b8101908080519060200190929190505050146100e457600080fd5b50565b610127806100f66000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806347d54a4514602d575b600080fd5b606c60048036036020811015604157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050606e565b005b6127108173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801560b657600080fd5b505afa15801560c9573d6000803e3d6000fd5b505050506040513d602081101560de57600080fd5b81019080805190602001909291905050501460f857600080fd5b5056fea165627a7a723058201eaa86ca0d93585836b0d06315ab78c83079efff596c1a0417c5195ad0fc9e2d0029&quot;;<br>  async function test(){    <br>   const contract = new web3.eth.Contract(abi);   <br>   const contractAddress = document.getElementById(&quot;contractAddress&quot;).value;    <br>   <em>// First we check max gas limit.</em>   <br>   let gasLimit = 8000029;    <br>   await web3.eth.getBlock(&quot;latest&quot;, false, (error, result) =&gt; {<br>    gasLimit = result.gasLimit;  <br>   });       <br>   contract.deploy({    <br>    data: bytecode,      <br>    arguments: [contractAddress]  <br>   }).estimateGas({ <br>    from: &#39;0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&#39;   <br>   }, (err, gas) =&gt; {    <br>    <em>// If there is no error and gas is bellow has limit the test succedded.</em>      <br>    if (err === null &amp;&amp; gas &lt; gasLimit) {              <br>     document.getElementById(&quot;console&quot;).innerHTML = &quot;Contract has 10000 tokens.&quot;     <br>    } else {     <br>     document.getElementById(&quot;console&quot;).innerHTML = &quot;Contract does NOT have 10000 tokens.&quot;     <br>    }   <br>   }); <br>  }  <br> &lt;/script&gt;   <br> &lt;h3&gt;Testing if ERC-721 enumerable contract has a total supply of 10.000.&lt;/h3&gt;   <br> &lt;h4&gt;Quick copy contract addresses for tests:&lt;/h4&gt;   <br> &lt;b&gt;Su Squares (passing test): &lt;/b&gt;0xE9e3F9cfc1A64DFca53614a0182CFAD56c10624F &lt;br/&gt;   <br> &lt;b&gt;Axie Infinity (failing test):   &lt;/b&gt;0xf5b0a3efb8e8e4c201e2a935f110eaaf3ffecb8d &lt;br/&gt;&lt;br/&gt;   <br> &lt;input id=&quot;contractAddress&quot; type=&quot;text&quot; placeholder=&quot;Input contract address&quot; /&gt;   <br> &lt;button onclick=&quot;test()&quot;&gt;Test&lt;/button&gt;   <br> &lt;p id=&quot;console&quot;&gt;&lt;/p&gt; <br>&lt;/body&gt; <br>&lt;/html&gt;</pre><p>This is an arbitrary test case written in Solidity. This test case can be called against arbitrary contracts and can use arbitrary data and make arbitrary calls to other contracts.</p><p>Oh, and P.S.:</p><p>This same test case can be run against any EVM network, such as Ethereum Mainnet, Wanchain, Ethereum Ropsten, Hyperledger Burrow, Proof of Authority Network and private chains.</p><h3>Stubs and Artifacts</h3><p>A stub is a specific, additional contract that is needed just to validate a test subject contract. For example, if you are validating an ERC-721 contract’s ability to transfer tokens, you will need a contract that is able to receive tokens. You can see a fully developed <a href="https://github.com/0xcert/erc721-validator/blob/096d04b01dec172576743fe6131df1fb45f33f24/contracts/validator.sol#L578">example at 0xcert</a>.</p><p>Here is a basic example for an ERC-721 receiver stub. Note that this example assumes that the contract owns a token. You can achieve this in multiple ways that are described in the next section. The “giver” technique is also implemented in the 0xcert example linked <a href="https://github.com/0xcert/erc721-validator/blob/096d04b01dec172576743fe6131df1fb45f33f24/contracts/validator.sol#L796">here</a>.</p><pre>pragma solidity 0.5.6; <br>import “https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/erc721.sol&quot;; <br>import “https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/erc721-token-receiver.sol&quot;; <br>contract StubsAndArtifacts <br>{ <br> <em>/** <br>  * @notice Deploy test contract with subject to be used for all tests. <br>  */</em> <br> constructor( <br>  ERC721 _testSubject, <br>  uint256 _tokenId <br> ) <br>  public <br> { <br>  <em>// This test assumes that this contract owns that particular _tokenId. You first</em> <br>  <em>// need to get a token. There are multiple ways to achieve this like “buying” it</em> <br>  <em>// before running test or using “the giver” technique. All of this is explained</em> <br>  <em>// below in the article.</em>   <br>  testDoesCorrectlyTransferData(_testSubject, _tokenId); <br> } <br> function testDoesCorrectlyTransferData( <br>  ERC721 _testSubject, <br>  uint256 _tokenId <br> ) <br>  public <br> { <br>  StubTokenReceiver stub = new StubTokenReceiver(); <br>  <em>// we expect failure</em> <br>  _testSubject.safeTransferFrom(address(this), address(stub), _tokenId, “ffff”); <br> } <br>} <br>contract StubTokenReceiver is <br> ERC721TokenReceiver <br>{ <br> bytes4 constant FAKE_MAGIC_ON_ERC721_RECEIVED = 0xb5eb7a03;<br> <em>/** <br>  * @dev Receive token and map id to contract address (which is parsed from data). <br>  */</em> <br> function onERC721Received( <br>  address _operator, <br>  address _from, <br>  uint256 _tokenId, <br>  bytes memory _data <br> ) <br>  public <br>  returns(bytes4) <br> { <br>  return FAKE_MAGIC_ON_ERC721_RECEIVED; <br> } <br>}</pre><p>In the same way that you can deploy stubs using the live testing technique, you may also test contract deployments.</p><h3>Limitations</h3><p>The presented technique brings a much-needed way of testing deployed contracts, but it is not without limitations. We would like to acknowledge the limitations and give solutions to some.</p><p>Since smart contract <a href="https://solidity.readthedocs.io/en/v0.4.24/contracts.html#events">events</a> are not accessible from within contracts, there is no way of testing them without actually performing a transaction. Therefore, testing whether an event is emitted is not possible with <strong>estimateGas</strong>.</p><p>Now let’s say you are testing something like transfer of tokens. To be able to transfer tokens you need to be the owner or an approved party. This is not a problem since <strong>estimateGas</strong> does not need to be signed by a private key and by such can be run from any address. That means you can run the transaction as the address that actually owns the tokens even though you do not have its private key.</p><p>Let’s say you want to test the <strong>safeTransferFrom</strong> method in an ERC-721 contract with no input from any of the token owners. For this, you need a receiver much like the one described in the <strong>Stubs and Artifacts</strong> section and that is able to receive the token. Preferably you would want to have multiple receivers with different kinds of passing/failing tests. You can solve this with minimum costs. All you need to do is create and deploy a few contracts that will act as receiver tests. Once they are deployed, you can test any ERC-721 contracts <strong>safeTransferFrom</strong> as long as you know an existing ID of that contract, and if the contract supports the enumerable extension, you can check it immediately this way.</p><p>In practice, it would work like so: find the token owner from token ID, now you can create an <strong>estimateGas</strong> on a <strong>safeTransferFrom</strong> with the destination of the test contract you already deployed. To show that it really is that simple, we’ve provided a working example of this method <a href="https://github.com/fulldecent/live-testing-with-estimateGas/blob/master/validator-example.html">here</a>.</p><p>What about a case that involves multiple parties that would need to provide approval/ownership? Well, that is a limitation that cannot always be solved completely gas-free. But let us give you two examples of how you could do it:</p><ol><li>If you would like to test an ERC-721 asset that you don’t own or that has not been minted yet, but the asset is for sale on <a href="https://opensea.io/">OpenSea</a>, your test case could run as the WETH account (which has 2 million Ether available), you could purchase the token on OpenSea, and then use that token as you please.</li><li>Another way is the <a href="https://github.com/0xcert/erc721-validator/blob/master/contracts/validator.sol#L1060">giver contract</a> approach. This workaround is not completely free but provides a way in which the token is completely safe. You can check the <a href="https://erc721validator.org/">ERC-721 Validator</a> to see it in action.</li></ol><h3>Conclusion</h3><p>We have presented a complete <strong>alternative to testing with clean room tools</strong> such as Truffle. The live test approach makes the entire state of the network available for your test cases. And because you do not care about how the test subjects were deployed, it is very simple to run a single test suite against many deployed contracts.</p><p><strong>Reading circle questions</strong></p><ul><li>Which test situations would be better for the clean room approach and for the live test approach?</li><li>Does the introduction of live testing limit the usefulness of Truffle and similar tools?</li><li>What are the benefits of using a live test approach for research on security vulnerabilities?</li><li>What changes could be made to the (Ethereum) network client to make live testing simpler?</li><li>Was the Ethereum Yellow Paper literally wrong, or is this a contrived interpretation?</li></ul><p><a href="https://erc721validator.org/"><strong>Check how ERC-721 Validator works</strong></a><strong><br></strong><a href="https://github.com/fulldecent/live-testing-with-estimateGas/"><strong>Check the complete code of live testing with estimateGas on GitHub</strong></a><strong><br></strong><a href="https://fulldecent.github.io/live-testing-with-estimateGas/validator-example.html"><strong>Check the validator example</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*K8LsozoElZIDhJ6t.jpg" /></figure><p><em>Originally published at </em><a href="https://0xcert.org/news/live-testing-smart-contracts-with-estimategas-william-entriken-tadej-vengust"><em>https://0xcert.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19920a55d65b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/0xcert/testing-smart-contracts-live-without-spending-gas-19920a55d65b">Testing smart contracts live without spending gas</a> was originally published in <a href="https://medium.com/0xcert">0xcert</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create 1 million (or more) NFTs with zero fees]]></title>
            <link>https://medium.com/0xcert/create-1-million-or-more-nfts-with-zero-fees-3a5374754b64?source=rss----30621f84231e---4</link>
            <guid isPermaLink="false">https://medium.com/p/3a5374754b64</guid>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[non-fungible-tokens]]></category>
            <category><![CDATA[atomic-operation]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[0xcert]]></dc:creator>
            <pubDate>Mon, 14 Oct 2019 09:58:37 GMT</pubDate>
            <atom:updated>2019-10-14T09:58:36.871Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*YUDdeSXmliQhDUIcr_nwEg.jpeg" /></figure><p>The <a href="https://github.com/0xcert/framework">0xcert Framework</a> provides multiple functionalities, some of which were explained in <a href="https://0xcert.org/news/0xcert-framework-tutorial-6-atomic-operations">previous tutorials</a>. Today, we are going to focus on one particularly potent part, namely <strong>atomic operations</strong>. We purposely called them atomic <strong>operations</strong>, <em>not</em> atomic swaps. What is the reason?</p><p>Well, let’s first take a look at the definition of an <strong>atomic swap</strong>. An atomic swap is defined as:</p><blockquote>A smart contract technique then enables the transfer of an asset between two parties without using a centralized intermediary.</blockquote><p>➡️ To learn more about atomic swaps, please check <a href="https://0xcert.org/news/dex-series-7-atomic-swaps">this article</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/0*Y6yRvSDAoMbaA8AE.jpg" /></figure><p>An atomic swap, as you can see, is what powers decentralized exchanges. But despite its potential, the same principals can be used in many other ways, as well.</p><p>This is where <strong>atomic operations</strong> come in, and these can be created within the 0xcert Framework <em>as</em> atomic orders. Currently, atomic operations in the 0xcert Framework can be used to <strong>create and update the state of NFTs</strong>, but there are many more operations that can ascend from it and will be supported in further iterations.</p><p>Now, how does an atomic operation allow us to <strong>create NFTs for free</strong>? It is by making <strong>atomic orders that can create NFTs</strong>.</p><p>This means that instead of creating a new NFT, you actually <strong>define an atomic order</strong> by describing the NFT you want to create and <strong>sign said order</strong>. The intended receiver of the NFT can then execute this order to claim the token, and by doing so, <em>they</em> end up paying the gas fee, not you. With this method, you can create an <strong>unlimited number of NFTs for free</strong> and <strong>delegate their creation cost</strong> to the receiver.</p><p>We call this <strong>delegate minting</strong>. This type of minting solves several problems for the creator of NFTs — instead of having to pay a bunch of ETH to create tokens, you (as a creator) just delegate the fees to the receiver; the receiver of the order, in turn, has the option to either execute the creation of NFT or not.</p><h3>Creating an atomic order for delegate mint</h3><p>In this tutorial, we will assume you already know the basics of the <a href="https://github.com/0xcert/framework">0xcert Framework</a> from our <a href="https://0xcert.org/news/how-to-create-1-million-nfts-for-free-with-0xcert-framework/link">previous tutorials</a>. In the introduction above, we talked about NFTs, but as mentioned in previous Framework tutorials, the <strong>NFTs are called assets</strong> within the 0xcert Framework.</p><p>Now, let’s go through the steps of <strong>creating an atomic order</strong> for our purpose of minting a million NFTs with no gas fees. A working code example for this tutorial can be found <a href="https://stackblitz.com/edit/create-unlimited-nfts">here</a>.</p><p><strong>⚠️ But before we start, we need to set up a few things:</strong></p><p><strong>1.</strong> Deploy a new <strong>assetLedger</strong> or instantiate an existing <strong>assetLedger</strong> with you as the owner (having the <a href="https://docs.0xcert.org/api/ethereum.html#ledger-abilities">super ability</a>).<br><strong>2.</strong> Allow <strong>orderGateway</strong> to create tokens for our <strong>assetLedger</strong>.<br><strong>3.</strong> Specify the accounts that will have the ability to actually sign an atomic order for asset creation.</p><p>For this tutorial, we will assume you already have a development environment set up and that you are the owner of a deployed <strong>assetLedger</strong>. If you do not have this set up yet, please check our <a href="https://docs.0xcert.org/guide/introduction.html">Documentation guide</a> or previous tutorials.</p><p>✅ Now that we have everything ready, let’s dive right in.</p><p>The first thing you need to do is to allow <strong>orderGateway</strong> to create new assets on your behalf. You do this by calling:</p><pre>await assetLedger.grantAbilities(   <br> orderGateway, <em>// instance of order gateway</em>     <br> [GeneralAssetLedgerAbility.CREATE_ASSET] <br>);</pre><p>Next, you need to specify who will be able to sign the atomic order that creates a new asset. Here’s how:</p><pre>await assetLedger.grantAbilities(   <br> &#39;0x...&#39;, <em>// account address (will be the maker od the order)</em>   <br> [GeneralAssetLedgerAbility.ALLOW_CREATE_ASSET] <br>);</pre><p>Once you grant these two abilities, you have everything ready to perform delegate mint. Granting of abilities only needs to be done once. After that, you can decide on creating as many orders of asset creation as you want — like so:</p><pre>import { OrderGateway, Order, OrderActionKind } from &#39;@0xcert/ethereum-order-gateway&#39;; <br><em>// Define atomic order</em> <br>const order = {    <br> makerId: &#39;0x...&#39;, <em>// Maker address (must have ALLOW_CREATE_ASSET ability)</em>    <br> takerId: &#39;0x...&#39;, <em>// Taker address (address that will perform the order)</em>    <br> actions: [      <br>  {          <br>    kind: OrderActionKind.CREATE_ASSET, <em>// Set action type to create asset</em>            <br>    ledgerId: assetLedgerId, <em>// ID of asset ledger where new asset will be created</em>            <br>    receiverId: &#39;0x...&#39;, <em>// Receiver address</em>        <br>    assetId: &#39;200&#39;, <em>// ID of asset to be created</em>               <br>    assetImprint: &#39;aa431acea5ded5d83ea45f1caf39da9783775c8c8c65d30795f41ed6eff45e1b&#39;, <em>// Imprint of asset to be created</em>      <br>  },  <br> ],    <br> seed: Date.now(), <em>// Unique order identification</em>    <br> expiration: Date.now() + 60 * 60 * 24 * 100, <em>// 100 days</em> <br>} as Order; <br><em>// Order Gateway address</em> <br>const orderGatewayId = &#39;0x0e4f45ad9bca9f214e73683f734f5b1aa3a4051a&#39;; <em>// Ropsten Order Gateway address</em> <br><em>// Create an instance of Order Gateway</em> <br>const orderGateway = OrderGateway.getInstance(provider, orderGatewayId); <br><em>// Sign the claim</em> <br>const signedClaim = await orderGateway.claim(order);</pre><p>At this point, the order is created an signed. What’s best, it was done with precisely zero gas consumed. You are now ready to send the order and <strong>signedClaim</strong> to the Taker.</p><p>A Taker can perform the order and by such, create the token as such:</p><pre>const orderGateway = OrderGateway.getInstance(provider, orderGatewayId); <br>const mutation = await orderGateway.perform(order, signedClaim); <br>await mutation.complete();</pre><h3>Marketplace — Any Taker</h3><p>In the atomic order we created above, we defined both the <strong>takerId</strong> and <strong>receiverId</strong>. Another option that the 0xcert Framework provides is a <a href="https://docs.0xcert.org/api/ethereum.html#order-gateway"><strong>dynamic order</strong></a> option that leaves <strong>takerId</strong> and <strong>receiverId</strong> undefined or sets them as <strong>null</strong> — this way, any account or wallet would have the ability to perform such order.</p><p>This option is perfect for creating a digital marketplace by defining asset creation in exchange for tokens (a single order can contain multiple actions). It allows you to <strong>simultaneously create an asset and sell it</strong>, all while paying zero fees in a single atomic transaction. This introduces the potential for even more powerful operations that expand the application possibilities of the <a href="https://github.com/0xcert/framework">0xcert Framework</a>.</p><h3>Conclusion</h3><p>In this mock-up case, we have demonstrated a way to create an <strong>unlimited amount of assets</strong> and paying <strong>zero gas fees</strong> in the process — more accurately, <strong>delegating the fees</strong> to the receiver. This method provides a number of possible use cases and prevents the network from having to execute a bunch of transactions at once.</p><p>We hope you enjoyed this and <a href="https://0xcert.org/news/0xcert-framework-tutorial-6-atomic-operations">previous tutorials</a>, and we’ll be happy to hear what you <a href="https://github.com/0xcert/framework/issues/442">came up with</a>.</p><p>If, however, you’re still stuck in the process and need a hand with checking your code, go and ask our developers in the <a href="https://0xcert.org/news/how-to-create-1-million-nfts-for-free-with-0xcert-framework/link">0xcert Gitter channel</a>, they will be glad to help you build the next big decentralized thing.</p><p><em>Originally published at </em><a href="https://0xcert.org/news/how-to-create-1-million-nfts-for-free-with-0xcert-framework/"><em>https://0xcert.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a5374754b64" width="1" height="1" alt=""><hr><p><a href="https://medium.com/0xcert/create-1-million-or-more-nfts-with-zero-fees-3a5374754b64">Create 1 million (or more) NFTs with zero fees</a> was originally published in <a href="https://medium.com/0xcert">0xcert</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[0xcert Quarterly Report — Q2 2019]]></title>
            <link>https://medium.com/0xcert/0xcert-quarterly-report-q2-2019-4192f365fadf?source=rss----30621f84231e---4</link>
            <guid isPermaLink="false">https://medium.com/p/4192f365fadf</guid>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[nonfungible-tokens]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[0xcert]]></dc:creator>
            <pubDate>Fri, 11 Oct 2019 17:30:09 GMT</pubDate>
            <atom:updated>2019-10-11T17:30:09.416Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*-_1gUIX_vxfOP1GoXIHwrw.jpeg" /></figure><h3>0xcert Quarterly Report — Q2 2019</h3><p><em>In the seventh month of the year, it’s time for a retrospective on the progress we’ve done in the past three months. Check the latest updates in the </em><a href="https://0xcert.org/news"><em>0xcert news section</em></a><em>, or subscribe to our newsletter in the footer below and have it all delivered to your inbox.</em></p><h3>Development</h3><p>Software and API development remains at the core of 0xcert’s nature. Similarly as <a href="https://0xcert.org/news/0xcert-quarterly-report-q1-19">before</a>, we’ve devoted the most of our time and resources to building new products and upgrading existing ones.</p><p>With the 0xcert Roadmap as our compass, we’re moving forward with new milestones met along the way.</p><h3>Development Roadmap</h3><p>The 0xcert <a href="https://www.google.com/url?q=https://0xcert.org/company/roadmap&amp;sa=D&amp;ust=1541158441769000&amp;usg=AFQjCNHhnLoNNwIqaaCXuaKUNB9G1FwkXQ">Roadmap</a> provides the most transparent insight into what has been achieved so far and the direction we’re moving to. Still, due to some pivots of focus required for rational utilization of resources, we’ve moved one milestone from Q2 towards the upcoming Q3 to guarantee its optimal execution.</p><p>Following the development of the Framework in Q1, we’ve continued to work on it and upgrade it in the past few weeks.</p><p><strong>1. The 0xcert Protocol v2.0 Aragorn</strong></p><p>The initial version of the 0xcert Protocol was built for Ethereum, the first blockchain network to support the creation and management of unique ERC-721 non-fungible tokens. Aligned with our endeavors to create a blockchain-agnostic framework for building dapps employing non-fungible tokens, we started adding a new blockchain to be supported by the 0xcert Framework.</p><p>After the Framework version 1.0.0 Odin, we have successfully released the <a href="https://0xcert.org/news/0xcert-framework-to-add-wanchain-as-2nd-provider"><strong>version 2.0.0</strong></a><strong> of the 0xcert Protocol called Aragorn</strong> and thus upgraded the Framework by adding the Wanchain blockchain to its realm.</p><p>A new, recreated approach to building decentralized applications has therefore spread to a second network and now allows for dapp development on <strong>both Ethereum and Wanchain blockchains</strong>. Its powerful conventions and support of ERC-721 non-fungible tokens remain to be the core features provided by the Framework’s audited and powerful JavaScript library.</p><p>To date, the 0xcert Framework has been upgraded to <strong>version 1.7.0</strong>, remains accessible as <strong>open-source software on </strong><a href="https://github.com/0xcert/framework"><strong>GitHub</strong></a> and provides comprehensive <strong>Framework </strong><a href="https://docs.0xcert.org/"><strong>documentation</strong></a> to assist dapp developers.</p><p>At the time of compiling the 0xcert Whitepaper v1 in 2018, we’ve planned the Framework 2.0 with the notification system and community-requested features to be released in Q2. However, due to our recent decision to start working on new dapps parallelly, we were forced to move the release of the Framework 2.0 to Q3. We are already approaching its release closely, and we plan to announce it soon as one of the first milestones reached in Q3 of 2019.</p><h3>Milestones</h3><p>In terms of the specific stages of development, some new checkmarks have been added to the Milestones spreadsheet.</p><p>The 0xcert Protocol has gained a v2 DEX implementation and a new ERC-721 implementation. Despite some unchecked boxes like Conventions, Devkit, and DEX and DXM dapps in Q2, we’re working on them as we speak and we plan to announce the newly released upgrades soon.</p><p>Due to our work on several fronts simultaneously, from Framework upgrades to new dapps, we expect to see a strong boost in announcements within the upcoming weeks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/0*OyP9xWFmwnaD0Aq8.jpg" /></figure><h3>Extras</h3><h4><strong>1. Fabr(x) integration</strong></h4><p>Improving the 0xcert Framework not only vertically, but horizontally, as well, we’re building cooperations with like-minded projects making the dapp world more accessible.</p><p>0xcert Framework has been integrated with <strong>Fabr(x)</strong>, a <a href="https://www.fabrx.io/">blockchain automation platform</a>, to allow a <strong>wider audience to issue and transfer non-fungible tokens</strong> with a single API call.</p><p>The Framework now supports Fabr(x) with <strong>HTTP Provider</strong> to communicate with the Ethereum node, <strong>Mutations</strong> or requests to alter the state of tokens, and <strong>Asset Ledger</strong>, an ERC-721-based smart contract for deploying NFT smart contracts on Fabr(x).</p><p>You can read more about it <a href="https://0xcert.org/news/0xcert-framework-integrated-with-fabrx">here</a>.</p><h4><strong>2. Bitski integration</strong></h4><p>To lower the adoption barrier of dapps for the users unfamiliar with the blockchain and the needed infrastructure, we’ve partnered with <a href="https://bitski.com/"><strong>digital wallet Bitski</strong></a> to allow for easy and user-friendly connectivity with the blockchain.</p><p>Bitski not only provides a straightforward blockchain log-in solution but also guarantees <strong>bank-grade security</strong> through hardware security modules with multiple security layers. Partnering with Bitski digital wallet was a no-brainer also because it supports both ERC-20 fungible tokens as well as ERC-721 non-fungible tokens, which makes the 0xcert Framework a perfect fit for it.</p><p>With this integration, Bitski has also become the <strong>third blockchain communication provider</strong> within the 0xcert Framework, right after HTTP and MetaMask. For all the users of the 0xcert Framework building dapps with minimal coding required, Bitski provides an intuitive UX and ultimate safety for users and their accounts.</p><p>You can read more about it <a href="https://0xcert.org/news/0xcert-framework-1.6.0-integrated-with-bitski">here</a>.</p><h4><strong>3. Fork of Ernst &amp; Young’s Nightfall</strong></h4><p>In mid-April, Ernst &amp; Young released a zero-knowledge proof technology for blockchain-based transactions called <a href="https://github.com/EYBlockchain"><strong>Nightfall</strong></a> to speed up business adoption of the blockchain tech.</p><p>0xcert has followed suit and shortly after forked the open-source code of Nightfall and replaced the standard ERC-721 token implementation with the <strong>enhanced, 0xcert-native ERC-721 token called Xcert</strong>. The Nightfall-provided features of private transactions have thus acquired two new qualities, namely <strong>interoperability, </strong>and <strong>certification</strong>.</p><p>With this fork, EY’s Nightfall software has gained a new improvement proposal for the benefit of their clients. 0xcert, on the other hand, continues to engage in the blockchain community and contribute to real-life adoption of the blockchain tech.</p><p>You can read more about it <a href="https://0xcert.org/news/0xcert-fork-of-ey-nightfall-with-added-features">here</a>.</p><h4><strong>4. Bug bounties</strong></h4><p>0xcert continues to encourage the developer community to propose edits or changes to the code and our publications through our <strong>bug bounties on GitHub</strong>:</p><ul><li>Bug Bounty for <a href="https://github.com/0xcert/ethereum-erc721/blob/master/BUG_BOUNTY.md">ERC-721 RC1</a>: to detect issues and provide suggestions for the RC1 improvements</li><li>Bug Bounty for the <a href="https://github.com/0xcert/framework/blob/master/BUG_BOUNTY.md">0xcert Framework</a>: to expose issues and submit improvement proposals in terms of code or documentation</li></ul><h3>Marketing</h3><h4>Events</h4><p>Since we’ve spent most of our time tirelessly developing our products and solutions, the Q2 of 2019 was somewhat publicity-shy. Still, we’re saving the best of our announcements for the upcoming weeks and months.</p><p><strong>HEK.SI Conference</strong></p><p>The two-day <a href="https://0xcert.org/news/0xcert-at-hek.si-ljubljana">HEK.SI Conference in Ljubljana</a> was devoted to ethical hacking and solutions for data breach issues in the digitally connected world.</p><p>On April 5, our CSO Urban Osvald held a talk about the threats and issues that the educational field faces in terms of certificate, data, and document forgeries. Aligned with the work of 0xcert, he provided an insightful solution to prevent and alleviate their consequences in the form of non-fungible tokens and data management on the blockchain.</p><h4>Content</h4><p>With the new addition to the 0xcert Framework, the Wanchain blockchain, we’re compiling new tutorials for building decentralized applications on this network, as well, following the Framework tutorial series for the <a href="https://0xcert.org/news/0xcert-framework-tutorial-1-run-and-prepare-geth-node-for-backend-integration">Ethereum blockchain</a>.</p><p>The objective is to provide developers with the same guidelines for building dapps regardless of the blockchain network they decide to employ.</p><h3>Ecosystem</h3><p>The community of actively non-fungible projects in the blockchain world, the <a href="https://nonfungiblealliance.org/"><strong>Non-fungible Alliance</strong></a>, continues gathering like-minded teams on a single platform for resources and knowledge exchange. With over <strong>100 members</strong>, the Alliance remains one of the epicenters of non-fungible activities and continues welcoming new projects and teams to join in.</p><p>Further supporting the developer community, the <a href="https://gitter.im/0xcert/framework"><strong>0xcert Gitter channel</strong></a> provides daily assistance to peer developers that encounter issues or challenges building their dapps.</p><p>In the second half of the year, the results of the previous months will culminate in some notable new releases, far beyond the premises we’ve established in the Whitepaper. To keep track of our work, we invite you to subscribe to our newsletter below and follow our social media channels.</p><p><em>Originally published at </em><a href="https://0xcert.org/news/0xcert-quarterly-report-q2-19"><em>https://0xcert.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4192f365fadf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/0xcert/0xcert-quarterly-report-q2-2019-4192f365fadf">0xcert Quarterly Report — Q2 2019</a> was originally published in <a href="https://medium.com/0xcert">0xcert</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[0xcert Framework upgraded to v1.8.0]]></title>
            <link>https://medium.com/0xcert/0xcert-framework-upgraded-to-v1-8-0-1223fd6eb373?source=rss----30621f84231e---4</link>
            <guid isPermaLink="false">https://medium.com/p/1223fd6eb373</guid>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[non-fungible-tokens]]></category>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[0xcert]]></dc:creator>
            <pubDate>Fri, 11 Oct 2019 17:29:18 GMT</pubDate>
            <atom:updated>2019-10-11T17:29:18.592Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*dNUYUbmL7-U-ii3f.jpg" /></figure><p>The 0xcert Framework for building dapps has just been updated to <a href="https://github.com/0xcert/framework/releases/tag/1.8.0"><strong>version 1.8.0</strong></a>.</p><p>The latest edition of the Framework brings upgrades on two fronts with:</p><p><strong>1.</strong> Added <strong>sign(message)</strong> support to providers<br><strong>2.</strong> Fixed minor bugs</p><p>With <strong>sign(message)</strong> support added to providers, you can now sign a message using your ETH account. The function enables both <strong>personal_sign</strong> and <strong>eth_sign</strong>, and it works for all blockchain communication providers within the 0xcert Framework.</p><p>After fixing minor code bugs, the Framework now runs even more smoothly and provides a better user experience for all dapp developers.</p><p>Soon, we’ll release a <strong>new version of the Framework</strong> with even more significant improvements, so stay tuned and follow our <a href="https://0xcert.org/news">news</a>.</p><p><strong>Create your next dapp with the 0xcert Framework!</strong></p><p>Choose your preferred blockchain network (Ethereum or Wanchain) and build your next powerful dapp by tomorrow.</p><p>If you experience trouble developing or if you have a question for our developers, meet them in the 0xcert <a href="https://gitter.im/0xcert/framework">Gitter channel</a>, and ask away.</p><p><em>Originally published at </em><a href="https://0xcert.org/news/0xcert-framework-1.8.0-latest-updates"><em>https://0xcert.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1223fd6eb373" width="1" height="1" alt=""><hr><p><a href="https://medium.com/0xcert/0xcert-framework-upgraded-to-v1-8-0-1223fd6eb373">0xcert Framework upgraded to v1.8.0</a> was originally published in <a href="https://medium.com/0xcert">0xcert</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Framework Tutorial for Wanchain #6] — Atomic operations in asset exchange]]></title>
            <link>https://medium.com/0xcert/framework-tutorial-for-wanchain-6-atomic-operations-in-asset-exchange-ed8082e340b3?source=rss----30621f84231e---4</link>
            <guid isPermaLink="false">https://medium.com/p/ed8082e340b3</guid>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[0xcert]]></dc:creator>
            <pubDate>Thu, 10 Oct 2019 13:16:29 GMT</pubDate>
            <atom:updated>2019-10-10T13:16:29.288Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*x8OaLn6xCNM2mCiEa3JRmA.jpeg" /></figure><h3>[Framework Tutorial for Wanchain #6] — Atomic operations in asset exchange</h3><p>The goal of this Wanchain tutorial series is to show how the <strong>0xcert Framework can be used with the Wanchain blockchain for building a dapp</strong>, as well as creating and managing non-fungible tokens.</p><p>⚠️ <em>Prefer building on Ethereum? </em><a href="https://0xcert.org/news/0xcert-framework-tutorial-6-atomic-operations"><em>This tutorial</em></a><em> should help.</em></p><h3>Before we begin</h3><p>This episode follows the <a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-5-transfer-assets?utm_medium=post&amp;utm_source=/news&amp;utm_campaign=framework%20tutorial&amp;utm_content=framework&amp;utm_term=previous%20tutorial">Tutorial #5</a> and assumes you have completed the step of transferring assets.</p><p><strong>In this tutorial series, you will learn:</strong></p><ol><li>How to set up a Wanchain test node (gwan)</li><li>How to create a Wanchain wallet and obtain test WAN tokens</li><li>How to set up Express server with TypeScript</li><li>How to connect Wanchain with the 0xcert Framework</li><li>How to use the 0xcert Framework for back-end</li><li>How to set up a simple front-end for testing</li></ol><p>At the end of the tutorial, you will be able to deploy, create, transfer, and query for information about non-fungible tokens on the Wanchain network.</p><p>To achieve this, we are using the following technologies:</p><ul><li>Wanchain testnet</li><li>TypeScript</li><li>Node.js</li><li>Express.js</li><li>0xcert Framework</li><li>jQuery</li></ul><p>It is assumed that you know and understand the basics of JavaScript, Node.js, jQuery, HTML, and usage of the terminal.</p><p>All the code used for examples can be found on <a href="https://github.com/MoMannn/wanchain-example">GitHub</a> with additional functions and explanations.</p><h3>1. Atomic order</h3><p>In this section, we will perform two atomic operations. We assume you know the basic principles of atomic operations within the 0xcert Framework, so if you’re unfamiliar with it, we suggest you read this <a href="https://0xcert.org/news/dex-series-7-atomic-swaps/">article</a>.</p><h4>1.1 Before we begin</h4><p>Atomic operations are performed via the <strong>Order Gateway structure</strong> which is deployed permanently on the platform and available to the public. The cryptographic mechanisms embedded in the Order Gateway structure guarantee protection for a fixed sequence of required steps and conditions.</p><h4>1.2 Installation</h4><p>First, we need to install the Order Gateway package:</p><pre>npm i --save @0xcert/wanchain-order-gateway</pre><h3>2. Usage overview</h3><p>For this tutorial, we will transfer an existent asset but also create a new asset and transfer it to our main digital wallet — all in a single atomic operation.</p><p>We should already have a deployed <strong>asset ledger</strong> from the previous steps, and now we can create another asset and send it to ourselves with ID <strong>100</strong>. We will be using that asset ledger and the newly created asset with ID 100 in our atomic operation.</p><p>We will also need to set up another wallet and unlock it to represent the Taker — check <a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-6-atomic-operations/link">Step 2</a> in the tutorial.</p><p>Now, we import a module into the application. In our case, we import the <strong>OrderGateway</strong> class that represents a wrapper around a specific pre-deployed structure on the Wanchain network.</p><pre>import { OrderGateway, Order, OrderActionKind } from &#39;@0xcert/wanchain-order-gateway&#39;;</pre><p>Next, we add a new API endpoint called the <strong>atomic-order</strong>.</p><pre>app.post(&#39;/atomic-order&#39;, async (req, res) =&gt; { <br>});</pre><p>In all the previous sections, we have created a front-end that required you to specify all the input parameters. But since atomic orders are a bit more complex and dynamic, we will hard code all the parameters and press a button on the front-end. In a real-world dapp, you would either handle this on the front-end, similarly to <a href="https://swapmarket.com/">SwapMarket</a> or generate an atomic order on the back-end yourself, depending on what you want to use it for. In this example, we only want to show how it works, so a primitive set-up like this is sufficient.</p><p>Next, we create a new instance of the <strong>OrderGateway</strong> class of an ID that points to a pre-deployed order gateway smart contract on the Wanchain testnet.</p><p>You can find the <strong>orderGatewayId</strong> for your preferred network <a href="https://docs.0xcert.org/api/wanchain.html#public-addresses">here</a>. Since this tutorial is made for building on the Wanchain testnet, we will copy the <strong>OrderGateway</strong> address from the Wanchain section.</p><pre>const orderGatewayId = &#39;0x90A8D7e2138ABB28393906Ae162238B5A18fE846&#39;; const orderGateway = OrderGateway.getInstance(provider, orderGatewayId);</pre><p>Now, we can define an operation with two actions:</p><ol><li>The first action will transfer an asset of ID <strong>1</strong> to our second wallet.</li><li>The second action will create (mint) a new asset of ID <strong>2</strong> and add it to our wallet.</li></ol><p>Every atomic operation has a Maker and a Taker. In this tutorial, we will act as both the Maker and the Taker of the order. For the <strong>makerId</strong>, we will use the gwan account we created at the begging of this tutorial, and for the <strong>takerId</strong>, we will use the one we created a few steps before.</p><p>This is how our order will look like:</p><pre>const account1 = &#39;0x...&#39;; <em>// 0x... - Account we used at the begging of the tutorial.</em> <br>const account2 = &#39;0x...&#39;; <em>// 0x... - Account we just created.</em> <br>const assetLedgerId = &#39;0x...&#39;; <em>// Your already deployed asset ledger.</em> <br>const order = {     <br> makerId: account1,     <br> takerId: account2,     <br> actions: [         <br>  {             <br>   kind: OrderActionKind.TRANSFER_ASSET,             <br>   ledgerId: assetLedgerId,             <br>   senderId: account1,             <br>   receiverId: account2,             <br>   assetId: &#39;1&#39;,         <br>  },         <br>  {             <br>   kind: OrderActionKind.CREATE_ASSET,             <br>   ledgerId: assetLedgerId,             <br>   receiverId: account1,             <br>   assetId: &#39;2&#39;,             <br>   assetImprint: &#39;0000000000000000000000000000000000000000000000000000000000000000&#39;, <em>// check certification section in documentation on how to create a valid imprint</em>         <br>  },     <br> ],     <br> seed: Date.now(), <em>// unique order identification</em>     <br> expiration: Date.now() + 60 * 60 * 24, <em>// 1 day</em> <br>} as Order;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*t9EQD0pv1z4dcZSE.jpg" /></figure><h3>3. Atomic order in action</h3><p>Atomic operations work in multiple steps and with multiple parties, as follows:</p><p><strong>1.</strong> Maker signs an atomic order.<br><strong>2.</strong> Maker approves their operations.<br><strong>3.</strong> Maker sends an order with a signature to the Taker.<br><strong>4.</strong> Taker approves their operations.<br><strong>5.</strong> Taker performs the atomic order.</p><p>For this example, we will do all of the above in one API call and therefore act as both the Maker and the Taker, and we will do all the operations in a single go. So there is no need for Step 3, since we already have all the needed information.</p><p>Let’s begin with <strong>Step 1</strong>.</p><pre>const signedClaim = await orderGateway.claim(order);</pre><p>By calling the <strong>claim</strong> function, we sign the order. Next, we need to send this signature to the Taker, together with the <strong>order</strong> object via an agreed communication channel.</p><p><strong>Steps 2 and 4</strong> are described below (each party should do this on their side):</p><p>For our example, we don’t have any actions that need approval from the Taker, so we only do the Maker’s part.</p><p>All parties participating in the operation must unlock the assets to be transferred and allow the <strong>OrderGateway</strong> to manage them. This step should be done by every person that participates in a transfer within order operations. In the example below, we authorize the <strong>OrderGateway</strong> to transfer the asset of ID <strong>100</strong> to another wallet address and grant it the ability to create (mint) assets.</p><p>The <a href="https://docs.0xcert.org/api/wanchain.html#approveoperator-accountid">API</a> section of the 0xcert Framework Documentation provides instructions on how to authorize the Order Gateway for all the assets simultaneously, to avoid authorizing only one asset at a time.</p><p>Order Gateway is comprised of multiple smart contracts. To save you the hassle of having to know their exact addresses, we handle all of this under one roof. However, the instance of <strong>OrderGateway</strong> is needed so that we know how to manage it. You may also decide to do this manually by finding the exact proxy contracts for the Order Gateway, but we recommend using Order Gateway Instance and let the 0xcert Framework handle that for you.</p><pre><em>// approve account for transfering asset</em> <br>await assetLedger.approveAccount(&#39;1&#39;, orderGateway).then((mutation) =&gt; {     <br> return mutation.complete();<br>});<br><em>// assign ability to mint</em> <br>await assetLedger.grantAbilities(orderGateway, [GeneralAssetLedgerAbility.CREATE_ASSET]).then((mutation) =&gt; {<br> return mutation.complete(); <br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*YtjzR4OFlx7W1-jO.jpg" /></figure><p>Make sure you create an instance of <strong>assetLedger</strong> and import <strong>GeneralAssetLedgerAbility</strong>.</p><p>For <strong>Step 5</strong>, we perform the order as a Taker (who will pay the network fee).</p><p>To specify that we perform this as a Taker, we will need to create a new instance of <strong>Provider</strong> and a new instance of <strong>OrderGateway</strong> with that provider, like this:</p><pre>const providerTaker = new HttpProvider({<br>  url: &#39;http://127.0.0.1:8545&#39;,<br>  accountId: account2, <br>  requiredConfirmations: 1 <br> });<br>const orderGatewayTaker = OrderGateway.getInstance(providerTaker, orderGatewayId);</pre><p>Now, we can execute the order and return the result:</p><pre>const mutation = await orderGatewayTaker.perform(order, signedClaim); res.send(mutation.id);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*RY-WFjIh8kTPLeV7.jpg" /></figure><p>To trigger the API, let’s add a button to our webpage,…</p><pre>&lt;h1&gt;Atomic order&lt;/h1&gt; <br>&lt;button id=&quot;atomicOrder&quot;&gt;Perform atomic order&lt;/button&gt; <br>&lt;p id=&quot;console&quot;&gt; &lt;/p&gt;</pre><p>…, add JavaScript code for the API call:</p><pre>$.ajax({ <br> contentType: &#39;application/json&#39; <br>}); <br>$(function(){ <br> $(&#39;#atomicOrder&#39;).click(function(){ <br>  $.post( <br>   &quot;http://localhost:3000/atomic-order&quot;,<br>   { }, <br>   function (response) {<br>    $(&#39;#console&#39;).html(&#39;&lt;a href=&quot;http://testnet.wanscan.org/tx/ + response + &#39; &quot; target=&quot;_blank&quot;&gt;Check transaction on block explorer&lt;/a&gt;.&#39;); <br>   } <br>  ); <br> }); <br>});</pre><p>Now we can trigger and check whether the atomic operations work as intended.</p><p>This is just a simple introduction to atomic operations. You can specify multiple actions and as such <strong>transfer multiple assets</strong>, <strong>create multiple new assets, update asset imprint</strong> and <strong>transfer value</strong>.</p><h3>4. Conclusion</h3><p>If you followed the tutorial, you hopefully learned something new about the Wanchain network and how to run their node, how to set up the Express server with TypeScript, and how to manage assets with the 0xcert Framework. To keep the tutorial readable, we only grazed all the functionalities that the 0xcert Framework provides. To learn more, you can check our <a href="https://github.com/0xcert/framework">GitHub</a> and <a href="https://docs.0xcert.org/">Documentation</a>. The whole tutorial is also available on GitHub <a href="https://github.com/MoMannn/wanchain-example">here</a>.</p><p>If you have questions about the code or you experience trouble developing your dapp, you can ask our developers for help in our <a href="https://gitter.im/0xcert/framework">Gitter channel</a>.</p><h3>What comes next?</h3><p>Congrats, you’ve made it to the end of our tutorial series for building dapps on the Wanchain network with the 0xcert Framework!</p><p>All that you have to do now is put the theory into practice, and <strong>create an awesome new dapp</strong>.</p><p><strong>⬇️Check other tutorial episodes, too⬇️</strong></p><p><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-1-run-and-prepare-wanchain-test-node-for-backend-integration">Framework tutorial for Wanchain #1: <strong>Run and prepare Wanchain test node for back-end integration</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-2-set-up-express-server-with-typescript-for-dapp-backend">Framework tutorial for Wanchain #2: <strong>Set up Express server with TypeScript for dapp back-end</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-3-deploy-asset-ledger">Framework tutorial for Wanchain #3: <strong>Deploy asset ledger</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-4-create-new-assets">Framework tutorial for Wanchain #4: <strong>Create new assets</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-5-transfer-assets">Framework tutorial for Wanchain #5: <strong>Transfer assets</strong></a></p><p><em>Originally published at </em><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-6-atomic-operations"><em>https://0xcert.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed8082e340b3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/0xcert/framework-tutorial-for-wanchain-6-atomic-operations-in-asset-exchange-ed8082e340b3">[Framework Tutorial for Wanchain #6] — Atomic operations in asset exchange</a> was originally published in <a href="https://medium.com/0xcert">0xcert</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Framework Tutorial for Wanchain #5] — Transfer assets]]></title>
            <link>https://medium.com/0xcert/framework-tutorial-for-wanchain-5-transfer-assets-f82c91760290?source=rss----30621f84231e---4</link>
            <guid isPermaLink="false">https://medium.com/p/f82c91760290</guid>
            <category><![CDATA[wanchain]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[0xcert]]></dc:creator>
            <pubDate>Thu, 10 Oct 2019 13:07:00 GMT</pubDate>
            <atom:updated>2019-10-10T13:06:59.899Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*0C28xWKEmBT6DdpYWMKxLA.jpeg" /></figure><h3>[Framework Tutorial for Wanchain #5] — Transfer assets</h3><p>The goal of this Wanchain tutorial series is to show how the <strong>0xcert Framework can be used with the Wanchain blockchain for building a dapp</strong>, as well as creating and managing non-fungible tokens.</p><p>⚠️ <em>Prefer building on Ethereum? </em><a href="https://0xcert.org/news/0xcert-framework-tutorial-5-transfer-assets"><em>This tutorial</em></a><em> should help.</em></p><h3>Before we begin</h3><p>This episode follows <a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-4-create-new-assets?utm_medium=post&amp;utm_source=/news&amp;utm_campaign=framework%20tutorial&amp;utm_content=framework&amp;utm_term=previous%20tutorial">Tutorial #4</a> and assumes you have created new asset(s) on Wanchain with the 0xcert Framework.</p><p><strong>In this tutorial series, you will learn:</strong></p><ol><li>How to set up a Wanchain test node (gwan)</li><li>How to create a Wanchain wallet and obtain test WAN tokens</li><li>How to set up Express server with TypeScript</li><li>How to connect Wanchain with the 0xcert Framework</li><li>How to use the 0xcert Framework for back-end</li><li>How to set up a simple front-end for testing</li></ol><p>At the end of the tutorial, you will be able to deploy, create, transfer, and query for information about non-fungible tokens on the Wanchain network.</p><p>To achieve this, we are using the following technologies:</p><ul><li>Wanchain testnet</li><li>TypeScript</li><li>Node.js</li><li>Express.js</li><li>0xcert Framework</li><li>jQuery</li></ul><p>It is assumed that you know and understand the basics of JavaScript, Node.js, jQuery, HTML, and usage of the terminal.</p><p>All the code used for examples can be found on <a href="https://github.com/MoMannn/wanchain-example">GitHub</a> with additional functions and explanations.</p><h3>Transfer assets</h3><p>Transferring an asset is quite simple. All you need is to know which asset you want to transfer (ID) and to whom you want to transfer it (address of the receiver). There are a few other options for transferring you can check <a href="https://docs.0xcert.org/api/wanchain.html#transferasset-recipe">here</a>, but this is basically all we need. So let’s put this into code the same way we did in the other examples so that we get all the parameters as inputs:</p><pre>app.post(&#39;/transfer&#39;, async (req, res) =&gt; { <br> const ledger = AssetLedger.getInstance(provider, req.body.assetLedgerId); <br> const mutation = await ledger.transferAsset({ <br>  receiverId: req.body.receiverId, <br>  id: req.body.id,<br> }); <br> res.send(mutation.id); <br>});</pre><p>The front-end will be the simplest yet:</p><pre>&lt;input id=&quot;address&quot; type=&quot;text&quot; placeholder=&quot;Asset ledger Id&quot; /&gt; &lt;br/&gt; <br>&lt;input id=&quot;id&quot; type=&quot;text&quot; placeholder=&quot;Id&quot; /&gt; &lt;br/&gt;<br>&lt;input id=&quot;recipient&quot; type=&quot;text&quot; placeholder=&quot;Recipient address&quot; /&gt; &lt;br/&gt; <br>&lt;button id=&quot;submit&quot;&gt;Transfer&lt;/button&gt; <br>&lt;p id=&quot;console&quot;&gt; &lt;/p&gt;</pre><p>And the jQuery call, as well:</p><pre>$.ajax({ <br> contentType: &#39;application/json&#39;<br>}); <br>$(function(){ <br> $(&#39;#submit&#39;).click(function(){ <br>  $.post( <br>   &quot;http://localhost:3000/transfer&quot;,<br>   {<br>    assetLedgerId: $(&#39;#address&#39;).val(), <br>    receiverId: $(&#39;#recipient&#39;).val(), <br>    id: $(&#39;#id&#39;).val(), <br>   }, <br>   function (response) {<br>    $(&#39;#console&#39;).html(&#39;&lt;a href=&quot;http://testnet.wanscan.org/tx/&#39; + response + &#39;&quot; target=&quot;_blank&quot;&gt;Check transaction on block explorer&lt;/a&gt;.&#39;); <br>   } <br>  ); <br> }); <br>});</pre><p>Try it with the following test data:</p><p><strong><em>Asset ledger ID (contract address):</em></strong> Copy from step 6<br><strong><em>ID:</em></strong> <em>1</em><br><strong><em>Recipient address:</em></strong> Any Wanchain address (it can be your own)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*yXyjpIxvkDQk51Ap.jpg" /></figure><p>Now, we can test it the same way we tested the other examples. If everything goes well, you should see the transaction on the block explorer.</p><p>If you have questions about the code or you experience trouble developing your dapp, you can ask our developers for help in our <a href="https://gitter.im/0xcert/framework">Gitter channel</a>.</p><h3>What comes next?</h3><p>Now that we have learned about transferring your assets, we can move forward to <strong>atomic operations</strong>.</p><p><strong>⬇️Check other tutorial episodes, too⬇️</strong></p><p><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-1-run-and-prepare-wanchain-test-node-for-backend-integration">Framework tutorial for Wanchain #1: <strong>Run and prepare Wanchain test node for back-end integration</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-2-set-up-express-server-with-typescript-for-dapp-backend">Framework tutorial for Wanchain #2: <strong>Set up Express server with TypeScript for dapp back-end</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-3-deploy-asset-ledger">Framework tutorial for Wanchain #3: <strong>Deploy asset ledger</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-4-create-new-assets">Framework tutorial for Wanchain #4: <strong>Create new assets</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-6-atomic-operations">Framework tutorial for Wanchain #6: <strong>Atomic operations in asset exchange on Wanchain</strong></a></p><p><em>Originally published at </em><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-5-transfer-assets"><em>https://0xcert.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f82c91760290" width="1" height="1" alt=""><hr><p><a href="https://medium.com/0xcert/framework-tutorial-for-wanchain-5-transfer-assets-f82c91760290">[Framework Tutorial for Wanchain #5] — Transfer assets</a> was originally published in <a href="https://medium.com/0xcert">0xcert</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Framework Tutorial for Wanchain #4] — Create new assets]]></title>
            <link>https://medium.com/0xcert/framework-tutorial-for-wanchain-4-create-new-assets-4f8c9e457623?source=rss----30621f84231e---4</link>
            <guid isPermaLink="false">https://medium.com/p/4f8c9e457623</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[wanchain]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[dapps]]></category>
            <dc:creator><![CDATA[0xcert]]></dc:creator>
            <pubDate>Thu, 10 Oct 2019 13:02:11 GMT</pubDate>
            <atom:updated>2019-10-10T13:02:11.399Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*aA856MnuHCzRKQ4fIw0cmQ.jpeg" /></figure><h3>[Framework Tutorial for Wanchain #4] — Create new assets</h3><p>The goal of this Wanchain tutorial series is to show how the <strong>0xcert Framework can be used with the Wanchain blockchain for building a dapp</strong>, as well as creating and managing non-fungible tokens.</p><p>⚠️ <em>Prefer building on Ethereum? </em><a href="https://0xcert.org/news/0xcert-framework-tutorial-4-create-new-assets"><em>This tutorial</em></a><em> should help.</em></p><h3>Before we begin</h3><p>This episode follows <a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-3-deploy-asset-ledger?utm_medium=post&amp;utm_source=/news&amp;utm_campaign=framework%20tutorial&amp;utm_content=framework&amp;utm_term=previous%20tutorial">Tutorial #3</a> and assumes you have deployed an asset ledger on Wanchain.</p><p><strong>In this tutorial series, you will learn:</strong></p><ol><li>How to set up a Wanchain test node (gwan)</li><li>How to create a Wanchain wallet and obtain test WAN tokens</li><li>How to set up Express server with TypeScript</li><li>How to connect Wanchain with the 0xcert Framework</li><li>How to use the 0xcert Framework for back-end</li><li>How to set up a simple front-end for testing</li></ol><p>At the end of the tutorial, you will be able to deploy, create, transfer, and query for information about non-fungible tokens on the Wanchain network.</p><p>To achieve this, we are using the following technologies:</p><ul><li>Wanchain testnet</li><li>TypeScript</li><li>Node.js</li><li>Express.js</li><li>0xcert Framework</li><li>jQuery</li></ul><p>It is assumed that you know and understand the basics of JavaScript, Node.js, jQuery, HTML, and usage of the terminal.</p><p>All the code used for examples can be found on <a href="https://github.com/MoMannn/wanchain-example">GitHub</a> with additional functions and explanations.</p><h3>Issue new assets</h3><p>Now that we have created an asset ledger, we can start creating new assets. If we look at the <a href="https://docs.0xcert.org/api/wanchain.html#createasset-recipe">documentation for creating assets</a>, we see that we need the ID of the asset ledger (the contract address we just copied in the previous step), and asset data which consists of a unique ID, an imprint (asset proof), and the address of the asset receiver. Just like before, we will create a POST call with all the data available as input parameters:</p><pre>app.post(&#39;/mint&#39;, async (req, res) =&gt; {<br> const ledger = AssetLedger.getInstance(provider, req.body.assetLedgerId); <br> const mutation = await ledger.createAsset({ <br>  receiverId: req.body.receiverId, <br>  id: req.body.id, <br>  imprint: req.body.imprint <br> }); <br> res.send(mutation.id); <br>});</pre><p>To test if this works, we will create a simple HTML page to test it:</p><pre>&lt;input id=&quot;address&quot; type=&quot;text&quot; placeholder=&quot;Asset ledger ID&quot; /&gt;&lt;br/&gt; <br>&lt;input id=&quot;id&quot; type=&quot;text&quot; placeholder=&quot;Id&quot; /&gt;&lt;br/&gt; <br>&lt;input id=&quot;recipient&quot; type=&quot;text&quot; placeholder=&quot;Recipient address&quot; /&gt;&lt;br/&gt; <br>&lt;input id=&quot;imprint&quot; type=&quot;text&quot; placeholder=&quot;Imprint&quot; /&gt;&lt;br/&gt;<br>&lt;button id=&quot;submit&quot;&gt;Create&lt;/button&gt; <br>&lt;p id=&quot;console&quot;&gt;&lt;/p&gt;</pre><p>And to call the API:</p><pre>$.ajax({ <br>  contentType: &#39;application/json&#39; <br>}); <br>$(function(){<br> $(&#39;#submit&#39;).click(function(){<br>  $.post( <br>   &quot;http://localhost:3000/mint&quot;, <br>   { <br>     assetLedgerId: $(&#39;#address&#39;).val(), <br>     receiverId: $(&#39;#recipient&#39;).val(), <br>     id: $(&#39;#id&#39;).val(), <br>     imprint: $(&#39;#imprint&#39;).val() <br>   },<br>   function (response) {<br>     $(&#39;#console&#39;).html(&#39;&lt;a href=&quot;http://testnet.wanscan.org/tx/&#39; + response + &#39;&quot; target=&quot;_blank&quot;&gt;Check transaction on block explorer&lt;/a&gt;.&#39;); <br>   } <br>  ); <br> }); <br>});</pre><p>Let’s reset our server and try if everything works. Let’s try it with the following test data:</p><p><strong><em>Asset ledger ID (contract address):</em></strong> Copy from step 5<br><strong><em>ID:</em></strong> <em>1</em><br><strong><em>Recipient address:</em></strong> Let’s send the asset to ourselves so copy your address here<br><strong><em>Imprint:</em></strong> <em>0000000000000000000000000000000000000000000000000000000000000000</em></p><p>Imprint represents the proof of our asset. For this example, we didn’t create a proof since we’re just using mock data everywhere. If you would like to know how to generate real proof, please read more <a href="https://docs.0xcert.org/guide/certification.html">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*CZJPOjcG7d66Fjme.jpg" /></figure><p>If we did everything well, we should see the transaction appear on the block explorer. Since we are now the owner of the asset with ID 1, we can transfer it to a new receiver.</p><p>If you have questions about the code or you experience trouble developing your dapp, you can ask our developers for help in our <a href="https://gitter.im/0xcert/framework">Gitter channel</a>.</p><h3>What comes next?</h3><p>Now that we have created a new asset in our dapp on Wanchain, we can start managing and <strong>transferring our assets</strong>.</p><p><strong>⬇️Check other tutorial episodes, too⬇️</strong></p><p><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-1-run-and-prepare-wanchain-test-node-for-backend-integration">Framework tutorial for Wanchain #1: <strong>Run and prepare Wanchain test node for back-end integration</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-2-set-up-express-server-with-typescript-for-dapp-backend">Framework tutorial for Wanchain #2: <strong>Set up Express server with TypeScript for dapp back-end</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-3-deploy-asset-ledger">Framework tutorial for Wanchain #3: <strong>Deploy asset ledger</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-5-transfer-assets">Framework tutorial for Wanchain #5: <strong>Transfer assets</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-6-atomic-operations">Framework tutorial for Wanchain #6: <strong>Atomic operations in asset exchange on Wanchain</strong></a></p><p><em>Originally published at </em><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-4-create-new-assets"><em>https://0xcert.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f8c9e457623" width="1" height="1" alt=""><hr><p><a href="https://medium.com/0xcert/framework-tutorial-for-wanchain-4-create-new-assets-4f8c9e457623">[Framework Tutorial for Wanchain #4] — Create new assets</a> was originally published in <a href="https://medium.com/0xcert">0xcert</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Framework Tutorial for Wanchain #3] — Deploy asset ledger]]></title>
            <link>https://medium.com/0xcert/framework-tutorial-for-wanchain-3-deploy-asset-ledger-caf2bad89562?source=rss----30621f84231e---4</link>
            <guid isPermaLink="false">https://medium.com/p/caf2bad89562</guid>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[wanchain]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[0xcert]]></dc:creator>
            <pubDate>Thu, 10 Oct 2019 12:04:41 GMT</pubDate>
            <atom:updated>2019-10-10T12:04:40.984Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*4K2IbgsyMJdRirgsJYpEgg.jpeg" /></figure><h3>[Framework Tutorial for Wanchain #3] — Deploy asset ledger</h3><p>The goal of this Wanchain tutorial series is to show how the <strong>0xcert Framework can be used with the Wanchain blockchain for building a dapp</strong>, as well as creating and managing non-fungible tokens.</p><p>⚠️ <em>Prefer building on Ethereum? </em><a href="https://0xcert.org/news/0xcert-framework-tutorial-3-deploy-asset-ledger"><em>This tutorial</em></a><em> should help.</em></p><h3>Before we begin</h3><p>This episode follows <a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-2-set-up-express-server-with-typescript-for-dapp-backend?utm_medium=post&amp;utm_source=/news&amp;utm_campaign=framework%20tutorial&amp;utm_content=framework&amp;utm_term=previous%20tutorial">Tutorial #2</a> and assumes you have set up Express server.</p><p><strong>In this tutorial series, you will learn:</strong></p><ol><li>How to set up a Wanchain test node (gwan)</li><li>How to create a Wanchain wallet and obtain test WAN tokens</li><li>How to set up Express server with TypeScript</li><li>How to connect Wanchain with the 0xcert Framework</li><li>How to use the 0xcert Framework for back-end</li><li>How to set up a simple front-end for testing</li></ol><p>At the end of this tutorial, you will have <strong>a connection between the 0xcert Framework and Wanchain established and asset ledger deployed</strong>.</p><p>To achieve this, we are using the following technologies:</p><ul><li>Wanchain testnet</li><li>TypeScript</li><li>Node.js</li><li>Express.js</li><li>0xcert Framework</li><li>jQuery</li></ul><p>It is assumed that you know and understand the basics of JavaScript, Node.js, jQuery, HTML, and usage of the terminal.</p><p>All the <strong>code used for examples</strong> can be found on <a href="https://github.com/MoMannn/wanchain-example">GitHub</a> with additional functions and explanations.</p><h3>Deploy an asset ledger</h3><p>The first thing we want to write is a way to deploy an <a href="https://docs.0xcert.org/guide/about-assets.html">asset ledger (ERC-721 smart contract)</a>. We create a POST HTTP request and call <strong>deploy</strong>:</p><pre>app.post(&#39;/deploy&#39;, async (req, res) =&gt; {<br> res.send(&#39;deploying&#39;); <br>});</pre><p>Now let’s see how deploying with the 0xcert Framework works. If we follow the <a href="https://docs.0xcert.org/api/wanchain.html#deploy-provider-recipe">specification</a>, we first need to connect to the blockchain through a provider. Since we are using our own node, we will be connecting through <strong>HttpProvider</strong>. We do this by adding the following lines before our API call definitions so that we can use it in every call:</p><pre>const provider = new HttpProvider({<br> url: &#39;http://127.0.0.1:8545&#39;,<br> accountId: &#39;0x...&#39;,<br> requiredConfirmations: 1<br>});</pre><p>Here we specified the <strong>url</strong> that points to our Wanchain node, the <strong>accountId</strong> that represents our Wanchain wallet and was generated in <a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-1-run-and-prepare-wanchain-test-node-for-backend-integration">Tutorial #1</a>, and we require at least one (1) confirmation before calling a mutation complete.</p><p>Now that we are connected to the Wanchain node, we can continue with deployment. For that, we need to set up an actual asset ledger, its name, symbol, and capabilities. To learn all about these parameters, check the <a href="https://docs.0xcert.org/api/wanchain.html#deploy-provider-recipe">official documentation</a>. For the API, we will just set all of these as POST parameters.</p><pre>app.post(&#39;/deploy&#39;, async (req, res) =&gt; {<br> const mutation = await AssetLedger.deploy(provider, {<br>  name: req.body.name, <br>  symbol: req.body.symbol, <br>  uriBase: req.body.uriBase, <br>  schemaId: req.body.schemaId, <br>  capabilities: req.body.capabilities<br> }); <br> res.send(mutation.id);<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*1UZ6yg_enaC-ihb7.jpg" /></figure><p>This code will now deploy a new asset ledger with specified parameters and then return the transaction hash which we can check on the Wanchain block explorer. This function will return the transaction hash as soon as it is known, but it will not wait for the transaction to be accepted onto the blockchain. For that, we would need to wait until completion with: <strong>await mutation.complete()</strong>.</p><p>To test this function, we can now write a super simple front-end. Let’s use <a href="https://jquery.com/">jQuery</a> for simplicity.</p><p>The HTML part is as follows (if you are not familiar with HTML, check the final product on <a href="https://github.com/MoMannn/wanchain-example">GitHub</a>.)</p><pre>&lt;input id=&quot;name&quot; type=&quot;text&quot; placeholder=&quot;Name&quot; /&gt;&lt;br/&gt; <br>&lt;input id=&quot;symbol&quot; type=&quot;text&quot; placeholder=&quot;Symbol&quot; /&gt;&lt;br/&gt; <br>&lt;input id=&quot;baseUri&quot; type=&quot;text&quot; placeholder=&quot;Base uri (http://example.com/)&quot; /&gt;&lt;br/&gt; <br>&lt;input id=&quot;schemaId&quot; type=&quot;text&quot; placeholder=&quot;Schema Id&quot; /&gt;&lt;br/&gt;&lt;br/&gt; <br>&lt;input type=&quot;checkbox&quot; value=&quot;1&quot; /&gt;Asset owner can destroy the asset&lt;br/&gt; <br>&lt;input type=&quot;checkbox&quot; value=&quot;2&quot; /&gt;Asset ledger owner can update assets&lt;br/&gt; <br>&lt;input type=&quot;checkbox&quot; value=&quot;3&quot; /&gt;Asset ledger owner can stop/start all asset transfers&lt;br/&gt; <br>&lt;input type=&quot;checkbox&quot; value=&quot;4&quot; /&gt;Asset ledger owner can revoke (destroy) any asset&lt;br/&gt;&lt;br/&gt; <br>&lt;button id=&quot;submit&quot;&gt;Deploy&lt;/button&gt; &lt;p id=&quot;console&quot;&gt;&lt;/p&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/0*fRLt9xS0HKXRj9PM.jpg" /></figure><p>The bottom line on the screen below appears after you click the Deploy button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*qthPlXxxmwJiwEmW.jpg" /></figure><p>JavaScript function API call (inside tags):</p><pre>$.ajax({<br> contentType: &#39;application/json&#39;<br>});<br>$(function(){<br> $(&#39;#submit&#39;).click(function(){<br>  const capabilities = [];<br>  $(&quot;input:checkbox:checked&quot;).each(function(){<br>   capabilities.push($(this).val());<br>  });<br>  $.post(<br>   &quot;http://localhost:3000/deploy&quot;,<br>   { <br>     name: $(&#39;#name&#39;).val(),<br>     symbol: $(&#39;#symbol&#39;).val(), <br>     uriBase: $(&#39;#baseUri&#39;).val(), <br>     schemaId: $(&#39;#schemaId&#39;).val(), <br>     capabilities: capabilities<br>   },<br>   function (response) {<br>     $(&#39;#console&#39;).html(&#39;&lt;a href=&quot;http://testnet.wanscan.org/tx/ +      response + &#39; &quot;target=_blank&quot;&gt; Check transaction on block explorer&lt;/a&gt;.&#39;);<br>   } <br>  ); <br> }); <br>});</pre><p>Now it’s time to try it out. First, we start Express with <strong>npm run start</strong>. Then, we open our webpage and insert all the data. You can use the example data below. If you are unfamiliar with <strong>schemaId</strong>, please check <a href="https://docs.0xcert.org/guide/certification.html">this introduction</a>.</p><p><strong><em>Name:</em></strong> Test<br><strong><em>Symbol:</em></strong> TST<br><strong><em>Base URI:</em></strong> <a href="http://test.com/">http://test.com/</a><br><strong><em>Schema ID:</em></strong> 0x0000000000000000000000000000000000000000000000000000000000000000</p><p>Next, we check a few capabilities. If we did everything right, we see that nothing happens when we press <strong>Deploy</strong> (if you get a CORS error in the browser console, scroll to the bottom of this section). But if we look at the Wanchain node, you will see an error saying <strong>“Account is not unlocked”</strong>. This is because the account we are using is locked and we cannot perform any mutation with it unless we unlock it. ⚠️ Please note that unlocking the account is <strong>dangerous</strong>, and before doing it in production, you should read all about <strong><em>Account management and security</em></strong>. For our example, however, we will unlock the account for an unlimited period of time. We do this by typing the following lines into the Wanchain node console:</p><pre>personal.unlockAccount(&quot;0x....&quot;, &quot;password&quot;, 0)</pre><p>Replace the first parameter with the address generated in <a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-1-run-and-prepare-wanchain-test-node-for-backend-integration">Tutorial #1</a> and replace the second parameter with your account’s password. The final parameter is time indicating how long the account should remain unlocked. Since we input “0”, the account will be unlocked for as long as the node is running or until we manually lock it back.</p><p>Now that we unlocked the account let’s try the <strong>Deploy</strong> function again. A link to the transaction should appear, and we should be able to open the Wanchain block explorer to see whether and when it was accepted onto the Wanchain network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Ko6_KbVvtdOdagHr.jpg" /></figure><p>The block explorer will show that a new contract was created. Let’s <strong>copy the contract address</strong> as shown above so that we can use it in the following steps when issuing new assets for this asset ledger. Note that it can take some time before the transaction is shown on the block explorer.</p><p>If the local set-up impedes the call to your API because of cross-origin error, you can add the following lines to the API functions and bypass it:</p><pre>res.header(&quot;Access-Control-Allow-Origin&quot;, &quot;*&quot;); <br>res.header(&quot;Access-Control-Allow-Headers&quot;, &quot;Origin, X-Requested-With, Content-Type, Accept&quot;);</pre><p>If you have questions about the code or you experience trouble developing your dapp, you can ask our developers for help in our <a href="https://gitter.im/0xcert/framework">Gitter channel</a>.</p><h3>What comes next?</h3><p>Now that we have deployed an asset ledger for our dapp on Wanchain, we can start <strong>creating (issuing) our assets</strong>.</p><p><strong>⬇️Check other tutorial episodes, too⬇️</strong></p><p><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-1-run-and-prepare-wanchain-test-node-for-backend-integration">Framework tutorial for Wanchain #1: <strong>Run and prepare Wanchain test node for back-end integration</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-2-set-up-express-server-with-typescript-for-dapp-backend">Framework tutorial for Wanchain #2: <strong>Set up Express server with TypeScript for dapp back-end</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-4-create-new-assets">Framework tutorial for Wanchain #4: <strong>Create new assets</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-5-transfer-assets">Framework tutorial for Wanchain #5: <strong>Transfer assets</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-6-atomic-operations">Framework tutorial for Wanchain #6: <strong>Atomic operations in asset exchange on Wanchain</strong></a></p><p><em>Originally published at </em><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-3-deploy-asset-ledger"><em>https://0xcert.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=caf2bad89562" width="1" height="1" alt=""><hr><p><a href="https://medium.com/0xcert/framework-tutorial-for-wanchain-3-deploy-asset-ledger-caf2bad89562">[Framework Tutorial for Wanchain #3] — Deploy asset ledger</a> was originally published in <a href="https://medium.com/0xcert">0xcert</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Framework Tutorial for Wanchain #2] — Set up Express server with TypeScript for dapp back-end]]></title>
            <link>https://medium.com/0xcert/framework-tutorial-for-wanchain-2-set-up-express-server-with-typescript-for-dapp-back-end-a48028a75653?source=rss----30621f84231e---4</link>
            <guid isPermaLink="false">https://medium.com/p/a48028a75653</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[wanchain]]></category>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[0xcert]]></dc:creator>
            <pubDate>Thu, 10 Oct 2019 11:38:13 GMT</pubDate>
            <atom:updated>2019-10-10T11:38:13.032Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*4XLrFcp1vUGlHgRx67nlaQ.jpeg" /></figure><h3>[Framework Tutorial for Wanchain #2] — Set up Express server with TypeScript for dapp back-end</h3><p>The goal of this Wanchain tutorial series is to show how the <strong>0xcert Framework can be used with the Wanchain blockchain for building a dapp</strong>, as well as creating and managing non-fungible tokens.</p><p>⚠️ <em>Prefer building on Ethereum? </em><a href="https://0xcert.org/news/0xcert-framework-tutorial-2-set-up-express-server-with-typescript-for-dapp-backend"><em>This tutorial</em></a><em> should help.</em></p><h3>Before we begin</h3><p>This episode follows <a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-1-run-and-prepare-wanchain-test-node-for-backend-integration?utm_medium=post&amp;utm_source=/news&amp;utm_campaign=framework%20tutorial&amp;utm_content=framework&amp;utm_term=previous%20tutorial">Tutorial #1</a> and assumes you have the Wanchain test node up and running.</p><p><strong>In this tutorial series, you will learn:</strong></p><ol><li>How to set up a Wanchain test node (gwan)</li><li>How to create a Wanchain wallet and obtain test WAN tokens</li><li>How to set up Express server with TypeScript</li><li>How to connect Wanchain with the 0xcert Framework</li><li>How to use the 0xcert Framework for back-end</li><li>How to set up a simple front-end for testing</li></ol><p>At the end of this tutorial, you will have a <strong>working Express server up and running</strong>.</p><p>To achieve this, we are using the following technologies:</p><ul><li>TypeScript</li><li>Node.js</li><li>Express.js</li></ul><p>It is assumed that you know and understand the basics of JavaScript, Node.js, and usage of the terminal.</p><p>All of the <strong>code used for examples</strong> can be found on <a href="https://github.com/MoMannn/wanchain-example">GitHub</a> with additional functions and explanations.</p><h3>1. Set up project and dependencies</h3><p>We assume you have installed <a href="https://nodejs.org/en/download/">node.js</a>. First, let’s create our project directory and initialize npm.</p><pre>$ mkdir wanchain-example<br>$ cd wanchain-example<br>$ npm init</pre><p>Now install all the required dependencies. First, install Express node that will run our API.</p><pre>npm install express</pre><p>The second dependency to be installed is TypeScript (we only need it as dev dependency since it’s no longer needed once it transpiles to JavaScript.):</p><pre>npm install --save-dev typescript</pre><p>Thirdly, we update our project so that TypeScript can handle type declarations for Express and node:</p><pre>npm install --save-dev @types/node @types/express</pre><p>Lastly, we install body-parser, which will help parse JSON data in Express.</p><pre>npm install body-parser</pre><p>With this, our project is set up from the standpoint of our API. Up to this point, this has been just a standard Express TypeScript set-up. What makes the magic happen is the 0xcert Framework.</p><p>For this tutorial, we will need two of the Framework’s packages. The first is <strong>HTTP-Provider</strong> which enables communication with the Wanchain node. The second is <strong>Asset-Ledger</strong> that channels all the operations we want to perform (deploy, create, transfer, etc.). Let’s add both:</p><pre>npm install @0xcert/wanchain-http-provider<br>npm install @0xcert/wanchain-asset-ledger</pre><p>Now we have all the necessary dependencies installed, and we can continue towards creating the API.</p><h3>2. Run Express with TypeScript</h3><p>Since we are running Express server with TypeScript, it requires a somewhat different set-up than the <a href="https://expressjs.com/en/starter/hello-world.html">hello world example</a> on their website. Here is that same example in TypeScript:</p><pre>import * as express from &#39;express&#39;;<br>const app = express();<br>const port = 3000;<br>app.get(&#39;/&#39;, (req, res) =&gt; {<br> res.send(&#39;Hello World!&#39;)<br> }); <br>app.listen(port, () =&gt; {<br> console.log(`Example app listening on port ${port}!`);<br>});</pre><p>Now, let’s create a folder called <strong>src</strong> containing a file <strong>index.ts</strong> and paste the above example inside it.</p><p>Before running it, we still need to configure both TypeScript and our project. For that, we first create a file called <strong>tsconfig.json</strong> in our root folder and add the following config:</p><pre>{<br> &quot;compilerOptions&quot;: {<br>  &quot;module&quot;: &quot;commonjs&quot;,<br>  &quot;target&quot;: &quot;es6&quot;,<br>  &quot;noImplicitAny&quot;: false,<br>  &quot;removeComments&quot;: true,<br>  &quot;sourceMap&quot;: true,<br>  &quot;outDir&quot;: &quot;dist&quot;,<br>  &quot;declaration&quot;: true,<br> }<br>}</pre><p>This config tells TypeScript how to compile to JavaScript. With it, we specified the output folder for JavaScript files to be <strong>dist</strong>. Now, we need to update <strong>package.json</strong> so it knows how to compile TypeScript to JavaScript and how to start the Express server. For that, we will need to update <strong>main</strong> and <strong>scripts</strong> sections as follows:</p><pre>&quot;main&quot;: &quot;dist/index.js&quot;, <br>&quot;scripts&quot;: {<br> &quot;build&quot;: &quot;tsc&quot;,<br> &quot;prestart&quot;: &quot;npm run build&quot;,<br> &quot;start&quot;: &quot;node .&quot;,<br> &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*pAvnNhRPCiP4i5pj.jpg" /></figure><p>We have set that the main file is a generated JavaScript file and that when we call <strong>npm run start</strong>, we first transpile TypeScript to JavaScript, and then start the Express server. Now we can run the <strong>npm run start</strong> command and see if everything works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*XE61kh08KqExsAyV.jpg" /></figure><p>Before we start writing the actual code, let’s add all the imports in our <strong>index.ts</strong> file:</p><pre>import * as express from &#39;express&#39;;<br>import * as bodyParser from &#39;body-parser&#39;;<br>import { HttpProvider } from &#39;@0xcert/wanchain-http-provider&#39;;<br>import { AssetLedger } from &#39;@0xcert/wanchain-asset-ledger&#39;;</pre><p>Lastly, we set up the <strong>body-parser</strong>, so we can parse JSON from POST calls.</p><p>This can easily be done by adding the following section after <strong>const app = express();</strong>:</p><pre>app.use(bodyParser.urlencoded({<br>  extended: true<br>}));<br>app.use(bodyParser.json());</pre><p>If you have questions about the code or you experience trouble developing with the 0xcert Framework on the Wanchain network, you can chat with our developers in the 0xcert <a href="https://gitter.im/0xcert/framework">Gitter channel</a>, they will be happy to help.</p><h3>What comes next?</h3><p>At this point, everything needed for this step has been set up, and we can start <strong>creating the API</strong>.</p><p><strong>⬇️Check other tutorial episodes, too⬇️</strong></p><p><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-1-run-and-prepare-wanchain-test-node-for-backend-integration">Framework tutorial for Wanchain #1: <strong>Run and prepare Wanchain test node for back-end integration</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-3-deploy-asset-ledger">Framework tutorial for Wanchain #3: <strong>Deploy asset ledger</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-4-create-new-assets">Framework tutorial for Wanchain #4: <strong>Create new assets</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-5-transfer-assets">Framework tutorial for Wanchain #5: <strong>Transfer assets</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-6-atomic-operations">Framework tutorial for Wanchain #6: <strong>Atomic operations in asset exchange on Wanchain</strong></a></p><p><em>Originally published at </em><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-2-set-up-express-server-with-typescript-for-dapp-backend"><em>https://0xcert.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a48028a75653" width="1" height="1" alt=""><hr><p><a href="https://medium.com/0xcert/framework-tutorial-for-wanchain-2-set-up-express-server-with-typescript-for-dapp-back-end-a48028a75653">[Framework Tutorial for Wanchain #2] — Set up Express server with TypeScript for dapp back-end</a> was originally published in <a href="https://medium.com/0xcert">0xcert</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Framework Tutorial for Wanchain #1] — How to run and prepare Wanchain test node for back-end…]]></title>
            <link>https://medium.com/0xcert/framework-tutorial-for-wanchain-1-how-to-run-and-prepare-wanchain-test-node-for-back-end-d3085646f78a?source=rss----30621f84231e---4</link>
            <guid isPermaLink="false">https://medium.com/p/d3085646f78a</guid>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[wanchain]]></category>
            <category><![CDATA[decentralized-apps]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[0xcert]]></dc:creator>
            <pubDate>Thu, 10 Oct 2019 11:31:07 GMT</pubDate>
            <atom:updated>2019-10-10T11:31:07.298Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*0YUzHtajVqHf4VsNZg78Tg.jpeg" /></figure><h3>[Framework Tutorial for Wanchain #1] — How to run and prepare Wanchain test node for back-end integration</h3><p>The goal of this Wanchain tutorial series is to show how the <strong>0xcert Framework can be used with the Wanchain blockchain for building a dapp</strong>, as well as creating and managing non-fungible tokens.</p><p>⚠️ <em>Prefer building on Ethereum? </em><a href="https://0xcert.org/news/0xcert-framework-tutorial-1-run-and-prepare-geth-node-for-backend-integration"><em>This tutorial</em></a><em> should help.</em></p><h3>Before we begin</h3><p><strong>In this tutorial series, you will learn:</strong></p><ol><li>How to set up a Wanchain test node (gwan)</li><li>How to create a Wanchain wallet and obtain test WAN tokens</li><li>How to set up Express server with TypeScript</li><li>How to connect Wanchain with the 0xcert Framework</li><li>How to use the 0xcert Framework for back-end</li><li>How to set up a simple front-end for testing</li></ol><p>At the end of this tutorial series, you will be able to <strong>deploy, create, transfer, and query for information</strong> about <strong>non-fungible tokens on the Wanchain network</strong>.</p><p>To achieve this, we are using the following technologies:</p><ul><li>Wanchain testnet</li><li>TypeScript</li><li>Node.js</li><li>Express.js</li><li>0xcert Framework</li><li>jQuery</li></ul><p>It is assumed that you know and understand the basics of JavaScript, Node.js, jQuery, HTML, and usage of the terminal.</p><p>All the code used for examples can be found on <a href="https://github.com/MoMannn/wanchain-example">GitHub</a> with additional functions and explanations.</p><p><strong>In this episode, we will accomplish the following:</strong></p><ol><li>Set up a Wanchain test node (gwan)</li><li>Create a Wanchain wallet and obtain test WAN tokens</li></ol><h3>1. Run the Wanchain node</h3><p>Wanchain is a fork of the Ethereum blockchain, so the basics are the same as for Ethereum.</p><p>First, we need to download the node software <a href="https://github.com/wanchain/go-wanchain/releases">here</a>. Since this tutorial was done using a Mac computer, we download <strong>gwan-mac-amd64–2.0.0-beta-c9bb9922.tar.gz</strong> (the latest version as of the time of writing this tutorial). This is the most recent <a href="https://medium.com/wanchain-foundation/wanchain-staking-beta-testnet-live-and-tps-increased-to-1000-19396e11ac4d">Wanchain POS testnet node</a>.</p><p>For mainnet, you need to install the previous 1.0.9 version (the latest as of our writing)</p><p>Now, we proceed to unzip the file, open terminal, and move to the folder location. We run the following command:</p><pre>./gwan console --testnet --rpc --rpcaddr &quot;localhost&quot; --rpcport &quot;8545&quot; --rpccorsdomain &quot;*&quot; --rpcapi=&quot;db,eth,net,web3,personal&quot;</pre><p>This initiates the Wanchain testnet node, which will be available at <strong>localhost:8545</strong>. By running it, a console will open up, and different extensions will become available for use. It will take a while for the node to update so you could take a 30 min break … ⏳ Well, not really, since you can just let the node run and sync, as we proceed with the tutorial, and we’ll come back to it later.</p><p>Here is how it looks like when the node starts <strong>syncing the proof of stake</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*oUa93ELaxi5K7zIm.jpg" /></figure><p>⚠️ <strong>Note:</strong> If you already had a previous testnet node installed and you updated it to the 2.0.0 beta version, there is a chance you will run into problems when syncing. In that case, remove all the chain data you had previously synced and run clean sync from the start.</p><h3>2. Create a new Wanchain account (wallet)</h3><p>In our newly open node console, we can create a new wallet for our project. We do this by writing</p><pre>personal.newAccount()</pre><p>into the console. This will prompt us to enter a passphrase. Choose a strong passphrase, write it down, and save it securely. The resulting hash is our public key/wallet, and you should copy it for later use.</p><p>Having a wallet is great and all, but we need to acquire some <strong>test WAN tokens</strong> before we can start playing with it. An excellent source for that is <a href="https://faucet1.wanchain.org/">Wanchain faucet</a> which uses social proof to prevent spam. That means you will need to post the hash copied from above to Twitter/Facebook or Google Plus and paste the public link to the website to get the test WAN tokens.</p><p>To check the Wanchain testnet and to see if you got the test WANs, go ahead and open their <a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-1-run-and-prepare-wanchain-test-node-for-backend-integration/%5Bhttp://testnet.wanscan.org%5D(http://testnet.wanscan.org/)">Testnet Block Explorer</a>, and insert the address into the search box. It may take a minute or so for the WANs to appear.</p><h3>What comes next?</h3><p>Now that you have created a new Wanchain account and acquired some test WAN tokens, you should be ready to <strong>start making JSON-RPC calls</strong> or use the <a href="https://github.com/0xcert/framework"><strong>0xcert Framework</strong></a> to do the dirty work for you.</p><p>The Framework is freely available on our <a href="https://github.com/0xcert/framework"><strong>GitHub</strong></a> and comes with a thorough <a href="https://docs.0xcert.org/?utm_medium=post&amp;utm_source=/news&amp;utm_campaign=dapp%20series&amp;utm_content=how_to_build_a_dapp&amp;utm_term=documentation"><strong>documentation</strong></a>. Feel free to use it for you next dapp and feel free to ask for assistance from our devs in the 0xcert <a href="https://gitter.im/0xcert/framework">Gitter chat</a>.</p><figure><a href="https://github.com/0xcert/framework?utm_medium=post&amp;utm_source=/news&amp;utm_campaign=series&amp;utm_content=outro&amp;utm_term=star%20github%20cta"><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*m9QgWUcahxEhoZ8p.jpg" /></a></figure><p><strong>⬇️Check other tutorial episodes, too⬇️</strong></p><p><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-2-set-up-express-server-with-typescript-for-dapp-backend">Framework tutorial for Wanchain #2: <strong>Set up Express server with TypeScript for dapp back-end</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-3-deploy-asset-ledger">Framework tutorial for Wanchain #3: <strong>Deploy asset ledger</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-4-create-new-assets">Framework tutorial for Wanchain #4: <strong>Create new assets</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-5-transfer-assets">Framework tutorial for Wanchain #5: <strong>Transfer assets</strong></a><br><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-6-atomic-operations">Framework tutorial for Wanchain #6: <strong>Atomic operations in asset exchange on Wanchain</strong></a></p><p><em>Originally published at </em><a href="https://0xcert.org/news/0xcert-framework-for-wanchain-tutorial-1-run-and-prepare-wanchain-test-node-for-backend-integration"><em>https://0xcert.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3085646f78a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/0xcert/framework-tutorial-for-wanchain-1-how-to-run-and-prepare-wanchain-test-node-for-back-end-d3085646f78a">[Framework Tutorial for Wanchain #1] — How to run and prepare Wanchain test node for back-end…</a> was originally published in <a href="https://medium.com/0xcert">0xcert</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>