<?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[Stories by Hoang Quan Tran on Medium]]></title>
        <description><![CDATA[Stories by Hoang Quan Tran on Medium]]></description>
        <link>https://medium.com/@shintran.1296?source=rss-1b7a8bb6ec97------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Opw35w_0ZW5Wn2rT.jpg</url>
            <title>Stories by Hoang Quan Tran on Medium</title>
            <link>https://medium.com/@shintran.1296?source=rss-1b7a8bb6ec97------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 16:41:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shintran.1296/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Tips for Vyper Beginners]]></title>
            <link>https://medium.com/coinmonks/for-those-who-is-going-to-learn-vyper-8bac3cc0e01c?source=rss-1b7a8bb6ec97------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bac3cc0e01c</guid>
            <category><![CDATA[vyper]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[Hoang Quan Tran]]></dc:creator>
            <pubDate>Sun, 15 Mar 2020 08:43:03 GMT</pubDate>
            <atom:updated>2020-08-23T10:05:44.482Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/674/0*cq93YUSgS3MUOXwG.jpg" /></figure><h4>There is something you should keep in mind</h4><ol><li>Vyper is not a replacement for Solidity but provides some advanced features in security, simplicity.</li><li>Vyper does not provide the dynamic type, class inheritance, function overloading, operator overloading, and recursion, modifier, inline assembly,…</li></ol><h4>The Vyper philosophy</h4><ol><li><strong>Security</strong>: It should be possible and natural to build secure smart-contracts in Vyper.</li><li><strong>Simplicity</strong>: Vyper’s goal to build a programming language that is easily understood and audited by a lay-person. Simplicity for the reader is more important than simplicity for the writer, and simplicity for readers with low prior experience with Vyper (and low prior experience with programming in general) is particularly important.</li></ol><blockquote><a href="https://medium.com/coinmonks/search?q=vyper"><strong>Read more article on Vyper programming Langauge</strong></a></blockquote><h3>Basic of installation, syntax, and example</h3><p>Vyper now is still in the experimental development stage, and <a href="https://vyper.readthedocs.io/en/latest/">official docs</a> is where you should start first. After that follow the list provided below:</p><ol><li><a href="https://github.com/vyperlang/vyper/wiki/Vyper-tools-and-resources">Tools and resources</a></li><li><a href="https://gitter.im/ethereum/vyper">Gitter channel</a> for quick help and discussion</li><li><a href="https://learnxinyminutes.com/docs/vyper/">Quick learning Vyper from zero</a></li><li>Besides examples from official docs, <a href="https://github.com/LayerXcom/verified-vyper-contracts">LayerX</a> verified Vyper smart contract is a good place to read and practice</li></ol><h4>Make a call to external contracts</h4><p>In <a href="https://blog.coincodecap.com/tag/smart-contact/">smart contract</a> development, we often call to external contracts to get state or executes. In Solidity, it is quite easy to walk around on the internet.</p><p>However in Vyper, it is still less information in some special case, that’s why I am writing this post.</p><p>Here are 2 ways in Vyper you can do this:</p><h4>Declares contract interfaces and make a call like Solidity:</h4><p>Interfaces can be added to smart contracts either through inline definition or by importing them from a separate file.</p><p>In addition, Vyper has built-in interfaces <strong>ERC20</strong>, <strong>ERC721, </strong>you can import with:</p><pre>from vyper.interfaces import ERC20</pre><p>To declare an interface, use the <strong>contract</strong> keyword as below:</p><pre># Declare contract interface FooBar with 2 function<br>contract FooBar:<br>    <strong>def</strong> calculate() -&gt; uint256: constant # get state of FooBar contract<br>    <strong>def</strong> test1(): modifying # A call will execute and change state of FooBar contract</pre><pre># Function make external call<br>@public<br>def makeCall(fooBarAddress: address):<br>    FooBar(fooBarAddress).calculate()  <em># cannot change storage</em><br>    FooBar(fooBarAddress).test1()  <em># storage can be altered</em></pre><p>Or you can call another contract with <strong>raw_call</strong>, a low-level built-in function that provide calls to the specified <a href="https://blog.coincodecap.com/tag/ethereum/">Ethereum</a> address with function signature and data, value.</p><p>Due to Vyper does not provide the dynamic type, that&#39;s mean if you call a Solidity contract at the function with a dynamic type like <strong>uint256[], raw_call </strong>is only way to do this.</p><p>For example, you have a function in Solidity like <a href="https://github.com/CryptoManiacsZone/1split/blob/master/contracts/IOneSplit.sol">this</a>:</p><pre>function swap(address fromToken, address toToken, uint256 amount,        uint256 minReturn, uint256[] memory distribution, uint256 disableFlags) public payable;</pre><p>You <strong>can not</strong> declare an interface in Vyper like the code below because Vyper does not provide dynamic type:</p><pre>contract IOneSplit:<br>   <strong>def</strong> swap(fromToken: address, toToken: address, amount: uint256, minReturn: uint256, distribution: uint256[], disableFlags: uint256) -&gt; uint256: modifying</pre><p>Or even you know the size of <strong>distribution (see the code below) </strong>and write an interface code like:</p><pre>contract IOneSplit:<br>   <strong>def</strong> swap(fromToken: address, toToken: address, amount: uint256, minReturn: uint256, distribution: uint256[4], disableFlags: uint256) -&gt; uint256: modifying</pre><p>The above code is the correct Vyper syntax but it is not <strong>swap </strong>function of <strong>OneSplit, </strong>cause function signature will be different between <strong>uint256[]</strong> and <strong>uint256[4].</strong></p><h4><strong>The one right way so far…</strong></h4><p>So the one and the only way to make a call from Vyper to function with dynamic arguments in Solidity contract is to make a call by using <strong>raw_call </strong>function with 4 bytes signature and data, value like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b07cfda541c811015ffe0961f48a3c36/href">https://medium.com/media/b07cfda541c811015ffe0961f48a3c36/href</a></iframe><p>The <strong>funSig </strong>variable is a function signature of <strong>OneSplit’s swap function </strong>and <strong>data: bytes[352]</strong> is 352 bytes of data will be passed as arguments in this function.</p><h3>References:</h3><ol><li><a href="https://github.com/vyperlang/vyper/wiki/Vyper-tools-and-resources">https://github.com/vyperlang/vyper/wiki/Vyper-tools-and-resources</a></li><li><a href="https://vyper.readthedocs.io/en/latest/index.html">https://vyper.readthedocs.io/en/latest/index.html</a></li><li><a href="https://learnxinyminutes.com/docs/vyper/">https://learnxinyminutes.com/docs/vyper/</a></li><li><a href="https://github.com/CryptoManiacsZone/1split/tree/master/contracts">https://github.com/CryptoManiacsZone/1split/tree/master/contracts</a></li><li><a href="https://blockgeeks.com/guides/understanding-vyper/">https://blockgeeks.com/guides/understanding-vyper/</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*5fZu_SfnNF6m_BGbXlsl-A@2x.png" /></figure><blockquote><a href="https://coincodecap.com/?utm_source=coinmonks">Get Best Software Deals Directly In Your Inbox</a></blockquote><figure><a href="https://coincodecap.com/?utm_source=coinmonks"><img alt="" src="https://cdn-images-1.medium.com/max/584/0*OJ-qb5G6i863msBB.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bac3cc0e01c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/for-those-who-is-going-to-learn-vyper-8bac3cc0e01c">Tips for Vyper Beginners</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>