fabiochiu/medium-articles huggingface dataset:
Learn Solidity: Variables (Part 3)
By: Wissal Haji
Tags: Solidity, Ethereum, Cryptocurrency, Programming, Blockchain

Arrays

In Solidity we have two types of arrays: storage arrays and memory arrays.

Storage arrays

These arrays are declared as state variables and can have either fixed or dynamic length.

Storage arrays with dynamic length can be resized, which means they have access to the push() and pop() methods.

Memory arrays

These arrays are declared with memory as their data location. They can also have either fixed or dynamic length, but dynamically sized memory arrays can’t be resized (i.e., can’t call push() and pop() methods); the size of the array must be calculated in advance.

Dynamically sized memory arrays are declared using the new keyword as follows:

Type[] memory a = new Type[](size)

One more point to mention here is about when you use memory arrays and you write something like this:

uint256[] memory array;

array[0] = 1;

You won’t get any warnings, but you will end up with an invalid opcode since array will be pointing to the zero slot according to the description of layout in memory, which should never be written to. Remember always to initialize the array before using it so that you can get a valid address to use.

Array slices

Array slices can only be used with calldata arrays and are written as x[start:end] . The first element of the slice is x[start] and the last element is x[end - 1] .
How To Create NFTs With Solidity
By: Patrick Collins
Tags: Solidity, Python, Cryptocurrency, Programming, Blockchain

On-Chain Metadata vs. Off-Chain Metadata

If you want your NFT to do anything interesting, in my mind, it needs to have on-chain attributes. A few examples include if you wanted to give them stats to battles like in Pokemon, some type of rarity stat, or have them have cryptographically guaranteed scarcity. The attributes would have to be on-chain.

Right now, NFT platforms don’t have great ways to visualize the on-chain attributes, so you just have to create a tokenURI with your minted NFTs.

Image from OpenSea D&D Characters.

For the tokenURI , one of the most popular approaches is using IPFS to store your data. You’ll upload your data there and then use a pinning service to make sure the data stays there forever. I’m excited for when we’ll have more interoperability between our smart contract platforms and our storage.

Hint: This goes into my blockchain full-stack theory. Smart contract platform on the front, Chainlink in the middle, dStorage on the back… but that’s another conversation.

Image from OpenSea.

To be honest, I thought NFTs were stupid at first. Then again, I’m also the type of dude who used to think art was dumb… but I have to remember I love music, movies, and games with good visuals, so I’d be a hypocrite if I said I didn’t like art. NFTs solve an issue that the art world is facing with royalties and authenticity. We now have a decentralized auditing service. If you want to use someone’s art, you can see everything about that piece of work on-chain.

The original creator of the Nyan cat sold an NFT version of it for 300 ETH. There is value in authenticity. If you create something amazing, there is value in scarcity. This is why I think having Chainlink VRF NFTs is so outstandingly amazing since you can create collectibles that are so rare that there could be a chance only you have it. I’m excited for when someone makes a Pokemon-type game on these platforms. These NFTs are here to stay.

There are a ton of NFT platforms that are skyrocketing in value, and we can do some really cool stuff with them.

Let’s look at my nft-mix I made on the Brownie platform. If you want an end-to-end demo showing how to upload to IPFS as well, check out the Chainlink blog we created that deployed these adorable little dungeons and dragons characters you saw above. Check out the description to see the code and the blog on that.

Let’s look at the code for a simple NFT. All the code for this can be found on the nft-mix repo on GitHub and the Dungeons and Dragons code can be found on GitHub as well.

To get the overall understanding of everything above, feel free to check out our youtube video on it.
Learn Solidity: Events
By: Wissal Haji
Tags: Solidity, Ethereum, Programming, Crypto, Blockchain

How To Declare and Trigger an Event

In order to declare an event, you need to use the following syntax:

The definition of the event contains the name of the event and the parameters you want to save when you trigger the event.

Once you have declared your event, you can emit an event from within a function, as follows:

emit MyEvent(block.timestamp, 'hello');

Let’s build an example to see how this actually works.

In your terminal, create a new directory and use truffle init to build a new truffle project. Open the project using your favorite code editor and create a new contract named EventExample.sol in the contracts folder, then copy-paste the following code:

Create the corresponding migration file 2_deploy_eventExample.js :

const EventExample = artifacts.require("EventExample"); module.exports = function (deployer) {

deployer.deploy(EventExample);

};

Let’s deploy now the contract using truffle migrate , but before migrating don’t forget to edit your truffle-config.js file to configure the network and the compiler.

In your terminal, start the Truffle console using truffle console .

We’re going to call the storeData function and examine the logs of the created transaction. Let’s start by getting an instance of the deployed contract:

let eventExample = await EventExample.deployed()

We can now call the function using:

let tx = await eventExample.storeData(10)

If you print the content of the transaction receipt logs tx.receipt.rawLogs , which store an array of the triggered events that happened during the execution of the transaction, you will get an array with one object that looks like this:

Transaction log

You can see that the event data is stored under the data field in hexadecimal.
Yield Farming Tutorial — Part 1. Smart Contracts Using Solidity and…
By: Andrew Fleming
Tags: Yield Farming, Solidity, Smart Contracts, Hardhat, Dapp Tutorial

2. PmknFarm Contract

touch contracts/PmknFarm.sol

In your PmknFarm contract, let’s build the skeleton of the project. We’re building a yield farming dApp; therefore, we’re going to need a function that allows users to stake their funds. We’re also going to need a function to unstake their funds. Further, users will want to withdraw their yield. So, three core functions. Import both the PmknToken contract and OpenZeppelin’s IERC20 contract. We also need to declare some state variable mappings and events for the front end. We’ll go over each aspect of the contract. First, let’s go over the constructor, state variables, and events.

The startTime and pmknBalance mappings may require a little explanation to better understand how they’ll be used in our functions. The startTime will keep track of the timestamp for the user’s address in order to track the user’s unrealized yield. The pmknBalance will point to the realized, or the stored amount waiting to be minted, PmknToken yield (not to be confused with actually minted PmknToken) associated with the user’s address. If you’re unfamiliar with mappings, they’re simply key/value pairs. For a more in-depth explanation, I encourage you to read the Solidity docs.

I always declare a name variable for testing; however, this is not required.

These state variable declarations precede with the type (ie IERC20, PmknToken) and visibility (public).

To avoid confusion, I encourage following this convention:

type => PascalCasing

state declaration => camelCasing

constructor parameter => _underscoreCamelCasing

When I first started working with Solidity, it took some time for me to understand what exactly was going on with utilizing ERC20 tokens. This is how I wish the concept was explained to me: The IERC20 and PmknToken consist of types; as in, the imported token type. The state variable declaration consists of the contract’s instance of the token type. Finally, the constructor’s parameter points to the address that fully creates a contract instance of the imported token.

The constructor, for those unfamiliar, is a function used once and only once during the deployment of the contract. A common use-case for a constructor includes setting constant addresses (just as we’re doing here). In order to deploy this contract, the user must input addresses for _daiToken and _pmknToken.

Onward to the heart of this article.
Introducing TR33 Finance. Token Feature
Tags: Solidity, Crypto, Defi

Token Features

TR33.Protocol features a 10% burn function (5% burns for ever and 5% goes to the burning wallet in the form of a deposit).(0x000000000000000000000000000000000000dead)

If you sell before 2 minutes your initial 5% deposit stays in the burn pot (dead address) for a GROWER to claim! Selling before 2 minutes of buying means you have failed to let the money tr33 blossom.

TR33 aims to make people who dump their tokens seconds after buying on UniSwap suffer. Every 20 minutes, a GROWER who buys the highest amount of TR33 tokens and doesn’t sell before 2 minutes gets the reward from the burn wallet, (0x000000000000000000000000000000000000dead). This reward can either be in the form of extra tokens upon buy back or a straight airdrop of tokens to the GROWER’s wallet!

The permanent burn means the supply of TR33 is always decreasing and becoming more and more scarce, Oh and there’s no mint function…

Tokenomics

· 5000 TR33 supply with constant burn from the 0x0 address

· 2500 TR33 reserved for presale

· 1000 TR33 reserved for liquidity on UniSwap

· 500 TR33 reserved for team — (TEAM WALLETS WILL BE PUBLIC)

· 1000 TR33 reserved for future staking

How will the presale work? + Details

An address will be pasted into our Telegram where people can send ETH.

1 ETH = 50 TR33||Min Send: 0.5ETH — Max Send: 2ETH.

1 TR33 = 0.02ETH

Soft Cap: 20ETH || Hard Cap: 50ETH, no large presale!

Listing price will be the same as presale to stop a harsh dump upon listing.

IF YOU SEND OVER 2 ETH WE WILL KEEP THE EXCESS SO DON’T DO IT

Where is the website or contract?

· Website: https://tr33protocol.com/

· Mainnet contract will be uploaded nearer to presale date, however we do have a ropsten contract ready for public viewing, here: https://ropsten.etherscan.io/address/0x81c875a30396dd795d2e5491b9bcb7946f94e709#code
Bug Bounty Program Launched Offering up to $25,000 for Critical Vulnerabilities in Collaboration with Immunefi
Tags: Solidity, Smart Contracts, Ethereum, Hacker, Bug Bounty

Bug Bounty Program Launched Offering up to $25,000 for Critical Vulnerabilities in Collaboration with Immunefi Fuse Follow Feb 23 · 2 min read

Fuse Network has experienced explosive liquidity growth in recent months. With this in mind, the Fuse team is taking the security of its key smart contracts, in particular on FuseSwap and Fuse Rewards, very seriously.

The bug bounty will distribute rewards to those who report issues in accordance with Immunefi’s severity scale, as follows.

Critical: USD 25,000

Critical bugs require that a smart contract suffer a complete loss or freeze of funds.

High: USD 10,000

High bugs are those that result in significant temporary issues like transient consensus failures or temporary inability to send funds.

Medium: USD 5,000

Medium-level bugs include, among others, smart contracts failing to use gas appropriately, block stuffing, and DDoS attack vulnerabilities.

Low: USD 1,000

Low-level bugs involve cases where smart contracts fail to deliver the promised returns but do not lose funds.

Bug Bounty Rewards will be distributed directly by the Fuse team, and the payouts are denominated in USD but will be made in FUSE tokens. White-hat hackers looking for a more detailed description of the program are encouraged to consult Immunefi’s article here:
Solidity Tutorial : all about Modifiers
By: Jean Cvllr
Tags: Solidity, Smart Contracts, Ethereum, Dapps, Blockchain

How do modifiers work?

Let’s start with some basic examples below.

modifier onlyOwner {

require(msg.sender == owner);

_;

}

The _; symbol

The symbol _; is called a merge wildcard. It merges the function code with the modifier code where the _; is placed. (give example in code).

In other terms, the body of the function (to which the modifier is attached to) will be inserted where the special symbol _; appears in the modifier’s definition.

Using the terms of the Solidity docs, it “returns the flow of execution to the original function code”.

A modifier must have the symbol _; within its body in order to execute. It is mandatory (does Solidity throw an error if it is not the case?).

Where to place the _; ?

The place where you write the _; symbol will decide if the function has to be executed before, in between or after the modifier code.

modifier SomethingBefore {

require(/* check something first */);

_; // resume with function execution

} // Do one where modifier is placed in the middle modifier SomethingAfter {

_; // run function first

require(/* then check something */)

}

As shown in the example above, you can place the _; at the beginning, middle or the end of your modifier body.

In practice, (especially until you understand how modifiers work really well), the safest usage pattern is to place the _; at the end. In this scenario, the modifier serves for consistent validation check, so to check a condition upfront and then carry on. The code snippet below show show this as example:

function isOkay() public view returns(bool) {

// do some validation checking

return true;

} function isAuthorised(address _user) public view returns(bool) {

// logic that checks that _user is authorised

return true;

} modifier OnlyIfOkAndAuthorised {

require(isOkay());

require(isAuthorised(msg.sender));

_;

}
How to Generate Truly Random Numbers in Solidity and Blockchain
By: Patrick Collins
Tags: Solidity, Ethereum, Cryptocurrency, Programming, Blockchain

Approach 1: Use the Current Blockhash

Since the blockchain is constantly growing, and the ID of each block hash constantly changing, we can just use that block has to get a random number, right? We can code this in solidity with this function:

function random() private view returns(uint){

return uint(keccak256(abi.encodePacked(block.difficulty, now, players)));

}

Note: This is actually using the block difficulty, which is similar in randomness.

Great! It would be too hard for someone to use the block hash to do anything malicious, right?

Wrong

A miner has the choice to publish a block or not. If they mine a block that they don’t like they can throw it out! If a group of miners do this, your numbers aren’t random anymore! This is feasibly quite easy for miners to do, and is rational for them to do too. Let’s say a miner signs up for a decentralized lottery for 10,000 ETH, and the winning ticket depends on the blockhash. They will just keep mining blocks and not publishing till they get the block they want! And they are incentivized to do this, since they will only be forgoing maybe 2–3 ETH, whereas if they win, the upside is massive.

A random number system needs to be so strong such that even if an attacker knows exactly how you’re creating the random numbers, it’s strong enough to still be unpredictable. By using the blockhash option, if someone is fast enough to see the hash, they can proceed to maliciously use this knowledge to “beat” whatever you’re using the random numbers for. Without true RNG, your lottery can always be hacked and stolen from.

Are you using this approach in a lottery application? Great, now they can use the hash to figure out the winning numbers every time. Meaning your lottery app is a “great-rich-quick” scheme for some random Kyle.

Potentially this random Kyle, although this one is a nice guy. Also not named Kyle. Photo by Hunter Johnson on Unsplash

Not only is someone who is faster at guessing the block hash going to be an issue, but we also have to put our faith in the miner who hashes the answer. We have to put faith that they will not use that knowledge to destroy our random application. Blockchain is designed to be as trustless as possible. So we have two major issues with using pseudo-random numbers.
Exploring Ethereum DApps
By: Manning Publications
Tags: Solidity, Ethereum, Dapps, Ethereum Blockchain, Blockchain

FREE EBOOK

In most applications data is collected, stored, and controlled by some central authority such as a bank, retailer, or governmental institution. Decentralized applications, or DApps, shift control to their users, operating without any single agency managing the process. Instead DApps store their data in a secure, unchangeable form called a blockchain, maintained concurrently on thousands of servers owned by different parties. Users do not need to trust any institution to be confident their data will be processed and stored correctly; the DApp technology itself guarantees it. The open-source Ethereum blockchain platform provides tools for developers to start building and deploying their own DApps, including an innovative smart contracts transaction model and Solidity, a JavaScript-like programming language.

Exploring Ethereum DApps is a free primer created with hand-picked chapters from Building Ethereum Dapps by Roberto Infante. It explains how decentralized applications work and gets you ready to start building them. You’ll quickly learn with what DApps look like, how they function, and what kind of application is best suited to being decentralized. Once you’ve grasped the basics you’ll dive into the Ethereum blockchain, including the Ethereum smart contracts that form the basis of all Ethereum DApps. When you’re done, you’ll have the grounding you’ll need to start building your first DApps.
Introduce and analyze Fixed Forex contract
By: 林瑋宸 Albert Lin
Tags: Solidity, Smart Contracts, Defi, Ethereum, Blockchain

I am very interested in this project, so I take a look at the contract code and do some research. Try to understand how to implement these features and the contract how work. Before we go through the contract, there is some information about the contract below. By the way, I can not sure the FixedUSD contract can represent all FixedForex contracts or not. But it is the only FixedForex contract I can survey. Maybe other FixedForex contracts will differ from the FixedUSD contract.



- Address:

- config:

- oracle =

- stable =

- router =

- aavev2 = 0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9

- iron back = 0xAB1c342C7bf5Ec5F02ADEA1c2270670bCa144CbB

- unitProcotol = 0x203153522B9EAef4aE17c6e99851EE7b2F7D312E FixedUSD:- Address: 0x92fc8e6efdf389e2527d14393b15f543f9a03420 - config:- oracle = 0xDA7a001b254CD22e46d3eAB04d937489c93174C3 - stable = DAI - router = SushiSwapRouter - aavev2 = 0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9- iron back = 0xAB1c342C7bf5Ec5F02ADEA1c2270670bCa144CbB- unitProcotol = 0x203153522B9EAef4aE17c6e99851EE7b2F7D312E

What are Loan-to-value ratios?

Loan to Value Ratio (LTV) is how lenders describe the amount you need to borrow to buy a particular property. In a nutshell: it’s the amount you need to borrow, calculated as a percentage of the property’s ‘lender-assessed value’.
Biswap — Discovery of Critical Vulnerability on Biswap’s swap() Function
Tags: Solidity, Ethereum, Bsc, Security, Biswap

Vulnerability Details

Figure 1. Biswap’s transaction fee mining mechanism

Ideally, Biswap has a transaction fee mining mechanism, as depicted in Figure 1. Every swap transaction on Biswap will have to pay a trading fee like other swap platforms. However, Biswap incentivizes users to swap on its platform by converting the trading fee to users’ fee return in the form of its native token — BSW.

For example, a user submits a transaction for swapping 1 BNB to Biswap’s Router (Step 1). Biswap’s Router transfers the user’s 1 BNB to Biswap’s Pair (Step 2). Later, Biswap’s Pair swaps 1 BNB for 300 BUSD to the user (Step 3).

Next, Biswap’s Router records the user’s transaction fee to Biswap’s SwapFeeReward (Step 4). Finally, the user can withdraw their fee return in BSW tokens (Step 5).

In Biswap, 100 million BSW tokens are allocated for the transaction fee mining. When compared to BSW’s total supply of 700 million tokens, the allocated 100 million tokens for the transaction fee mining considers the enormous portion.

Figure 2. An attacker can bypass the Router and mint BSW tokens for free

We found the critical vulnerability issue on the swap function of Biswap’s SwapFeeReward contract. This issue allowed the attacker to bypass the Biswap’s Router and execute transactions for recording arbitrary transaction fees without requiring the real swap, as shown in Figure 2.

Figure 3. The associated swap function of Biswap’s SwapFeeReward contract

Figure 3 shows the swap function , a part of the transaction fee mining mechanism used by the Biswap platform. Typically, Biswap’s Router would execute this associated function after a user swaps their tokens on the platform to record the user’s fee return.
First Defiville Hackathon
Tags: Solidity, Smart Contracts, Ethereum, Nft, Hackathons

Ladies and gentlemen…and pirates, welcome to the first Defiville hackathon, where dreams become reality and reality becomes a dream.

We have 6 bounties on Gitcoin for all the intrepid hackers and designers that want to gain fame and glory and a fair bit of shiny ISLA.

You can follow along and post your submission on our dedicated Discord channel: https://discord.gg/5RdBwMa8JT

So without further due, here are the bounties!

Developers bounties — Vending machines

Anon Vending

This is for the degen that doesn’t want to let their wife know that they are spending their retirement in pink kitties and pixelated punks.

That’s why we need an anonymous vending machine that you can use to purchase NFTs.

Whatever happens on the island, stays on the island.

This vending machine will let you create a sale and buy NFTs anonymously

Gitcoin link: https://gitcoin.co/issue/Defiville/Hackathon/4/100025370

Bonding Vending

This vending will allow anyone to create a sale for an NFT or ERC20 that follows a bonding curve on the price sale, pretty much like Unisocks.

So whether you want to create the next socks or any crazy idea, this is the place to be.

Gitcoin link: https://gitcoin.co/issue/Defiville/Hackathon/6/100025371

Crowdfounding Vending

You know Kickstarter right?

Perfect, because this vending is pretty much the same thing.

You have an idea or product to promote and you need funding? This is where you want to go ;)

Gitcoin link: https://gitcoin.co/issue/Defiville/Hackathon/7/100025372

Artists bounties

We haven’t forgotten about the artist.

Defi is not all code and dark terminal windows but also a great place for artists to express themself.

That’s why we have 3 juicy bounties for you as well.

Create a new building for the island

Everyone is hard at work to build the new world, but we need your sweat and blood to build something new and unique.

You will be the architect of this unique creation that will be erected on the island.

We are all waiting for your masterpiece.

Gitcoin link: https://gitcoin.co/issue/Defiville/Hackathon/5/100025368

Best stickers

When we are not hard at work on the island we are usually shitposting in our Telegram group and stickers are the essential tool for every shitposter.

Create one or more stickers and come to see a shower of emojis in your honour.

Gitcoin link: https://gitcoin.co/issue/Defiville/Hackathon/2/100025366

Best meme

Do you know what else we like?

A good meme, that’s all we love.

Become the king of memes and receive eternal gratitude from every islander that will laugh at your meme.

Gitcoin link: https://gitcoin.co/issue/Defiville/Hackathon/1/100025367

That's it for this hackathon.

We hope you get the chance to participate, have fun and hopefully learn something new.

The Defiville Team
Cloud native C++ microservice. Part 2 — What is cloud-native? Let’s make Solidity compiler service.
By: Andrey Bronin
Tags: Solidity, Cpp, Microservices, Cplusplus, Compilers

Modern Cloud-native C++ microservice. Part 2 — What is cloud-native? Let’s make Solidity compiler service.

Let’s make Solidity compiler microservice

Subject

Let’s do something useful. Imagine we make online IDE for Solidity(like Etherium Remix) We have SPA frontend and now we need scalable high performance compiler on backend. We have reference C++ implementation of Solidity and Javascript Emscripten compiled Solidity.

Now we could make C++ and NodeJS version of microservice and check which will be faster. Theoretically, C++ version should be much faster.

Now Let’s define requirements and service architecture. Before that, we need to learn what microservices are.

What is cloud-native application?

Cloud-native description, according to CNCF.

Cloud native technologies empower organizations to build and run scalable applications in modern, dynamic environments such as public, private, and hybrid clouds. Containers, service meshes, microservices, immutable infrastructure, and declarative APIs exemplify this approach. These techniques enable loosely coupled systems that are resilient, manageable, and observable. Combined with robust automation, they allow engineers to make high-impact changes frequently and predictably with minimal toil.

Cloud-native apps are developed with loosely-coupled microservices, allowing each microservice to function only as needed, as well as be updated/altered as needed, rather than requiring the full application to run aggregately.

In this article series will be described and implemented a few key attributes of Cloud-Native app.

Containerization

CI/CD pipeline

APIs for interaction and collaboration

Observability and analisys

Messanging

Functional Requirements

Worker Service should be able to compile solidity contracts to binary representation. Worker should use pub/sub pattern to interact with other services.

The Publisher publishes contract jobs to the Redis, workers do jobs and publish compiled contracts back to the Redis.

Redis Pub/Sub

Common Requirements

Service should be containerized and managed by orchestrator(Docker, Kubernetes)

Service inside container should be configuable by command line arguments or env variables.

Service logs should be formatted and structured

Service should provide health check

Service should metrics to observability service

Target platform

We will use two most popular Linux distro as docker base images: Ubuntu, Alpine. Alpine Linux is based on musl C library and BusyBox and gives tiny images, but it could be slower in some cases. First reason is glibc, second is default optimization compile option. I read somewhere, that packages build with compile option -Os which means “optimize for size” not for performance.

Future articles
BarnBridge Joins Immunefi with $500,000 Bounty
Tags: Solidity, Barnbridge, Smart Contracts, Armor Alliance, Bug Bounty

BarnBridge is joining Immunefi today with a $500,000 critical smart contract bug bounty.

BarnBridge is a risk tokenization protocol. It aims to reduce the risks associated with DeFi, such as interest rate fluctuations and asset price volatility. By letting users select a risk profile, BarnBridge can redistribute risk via tokenized, liquid tranches. BarnBridge does this with its SMART Yield, SMART Exposure, and upcoming SMART Alpha products, all of which address a specific DeFi risk category.

This bug bounty is intended to incentivize responsible disclosure from ethical hackers and functions like a decentralized, ongoing code review, as opposed to static audits, which have proved insufficient at stopping hacks.

The bounty of $500,000 comes from BarnBridge’s membership in the Armor Alliance, a bug bounty matching program created by Armor, a DeFi insurance protocol. BarnBridge’s base payout for critical bugs is up to $250,000 and the Armor Alliance provides an additional $250,000 for a total of up to $500,000 to any bug hunter who finds a critical smart contract vulnerability. Critical smart contract bugs are capped at 10% of economic damage. Rewards are distributed according to bug impact.

Boosting incentives is important; since 2019, DeFi hacks have led to more than $285 million in losses. If we can do our part to raise the incentive to responsibly disclose, we’ll reduce the likelihood of hacks.

We’re pleased that BarnBridge chose Immunefi to host its bug bounty program, as Immunefi is the top platform for bug bounties in Web3. We’ve saved more than $1 billion in user funds from being stolen due as a result of stopping vulnerabilities in code. We’ve paid out more than $3 million in bounties to ethical hackers. And, importantly, we’re currently guarding more than $25 billion in funds across all the protocols on our platform.

Bug bounties are a win-win. They’re good for the project. They’re good for the whitehat. They’re good for the DeFi community. They’re good for users. The only people bug bounties aren’t good for is malicious blackhats. And that’s okay with us.

We are excited about this collaboration with BarnBridge and encourage our Whitehat Army to start looking through the code, finding vulnerabilities, getting paid, and building rep.

To see more details on BarnBridge’s bug bounty program with Immunefi, see their bounty page here.
Matic Network: Bounty program for ETH India
By: Siddharth Jain
Tags: Solidity, Ethereum, Dapps, Hackathons, Blockchain

Hey folks!

Matic Network will be participating in ETH India’s second edition from August 2nd — 4th! And as it’s happening in our backyard Bangalore — India, we couldn’t be more excited!

Having seen the amazing hacks last year at the event we are excited for this upcoming edition of the ETH India! The community is stronger than ever and we believe that this edition will result in some gems that will move the space forward just like InstaDApp and Incento did in 2018.

We will be having a one hour intro to solidity workshop for Developers new to the Ethereum ecosystem.

Also as a part of our efforts to support developers, Matic is offering Bounties to developers building Hacks on Matic’s scaling solution.

Matic’s support to the teams building on our platform isn’t just restricted to the hackathon.

We support dev teams who want to continue building on the ideas they work on during the hackathon and help them deliver a functional product to the ecosystem.

Case in Point: Incento — the recipient of support from Matic’s Developer Support Program. A hackathon Idea born in ETHIndia and now being implemented on the Matic Alpha-Mainnet for the whole world to test!
Transaction confirmed: Tenderly beta now open to public
By: Bogdan Habic
Tags: Solidity, Debugging, Smart Contracts, Ethereum, Monitoring

I must admit: the title took me longer to think of than the rest of this article, but I digress before even starting. Welcome, to the copywriting playground of mine that is the Tenderly blog (I’m a developer, this is hard, please send help).

Tenderly beta now live!

I cannot be more happy to announce that the Tenderly beta is now open to everyone! Head on over to https://tenderly.co/, click on Start Monitoring, and in less than 5 minutes you can start tracking your Smart Contracts in real-time!

Once you have your account all set up, create a project and push your contracts to it. It’s effortless, and the project creation wizard takes you through it.

If you want to poke around the dashboard, without pushing your contracts, you can add any verified contract from Etherscan. A good example is the MakerDAO OasisDex contract which can be found at the address: 0x39755357759ce0d7f32dc8dc45414cca409ae24e. Again, create a project, select the import Verified Contract option, enter the address, and voila: Contract added and ready to monitor!

Right now error tracking is generally available, with alerting coming up next.

Below you can see an example stack trace for a failed transaction:
The quest for solidity. Week 1 :” The quest for solidity”
Tags: Solidity, Hack, Smart Contracts, Ethereum

Week 1 :” The quest for solidity”

As our Telegram group is about to reach 3000 members, we wanted to give you more details about what is going on behind the scenes.

The Trontopia project was born a couple of months back, started by a team of blockchain gamers full of energy and wanting to bring something new to the space.

A platform that you don’t need to trust, (trustless) where the game logic and every single functions are coded into smart contracts.

We are willing to make those contracts open source and visible to any players.

No tricks, no hidden code.

We intend to show that true provable fairness and transparency is possible to achieve in the TRON DAPPS ecosystem, and that users could highly benefit from it.

The challenging nature of crypto, especially the blockchain gaming space is that it is fairly a new technology, and that it requires a special attention to code.

Since the postponed launch announcement on monday, our team really took a step back, and we have started to look for some of the best Solidity developers in the game to assist us and ask them if they could audit our code.

We are currently in talks with a very well respected Smart contract audit team that we will announce shortly.

Those developers are all top tier / senior auditors and will make sure to provide a flawless code.

At Trontopia we love challenges, and always taking things that are happening to us as a lesson to grow and adapt.

Important changes were needed, and we are now taking the proper measures and associating with the right teams.
Ethereum Smart Contract Implicit Return can go wrong!
By: Paresh Masani
Tags: Idex, Araw, Solidity, Ethereum

Recently ARAW (araw.io) was listed on the IDEX and immediately they had to de-list due to deposits were failing on their platform. IDEX team tried to investigate the issue but it wasn’t straight forward issue to resolve. That’s where the technical challenge came to me. It’s one of my favourite things to investigate technical problems.

IDEX Smart Contract

https://etherscan.io/address/0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208#code

The issue created due to the following line

if (!Token(token).transferFrom(msg.sender, this, amount)) throw;

Open Zepplin Standard for TransferFrom function is

function transferFrom(

address _from,

address _to,

uint256 _value

)

public

returns (bool)

{

require(_to != address(0));

require(_value <= balances[_from]);

require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value);

balances[_to] = balances[_to].add(_value);

allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);

emit Transfer(_from, _to, _value);

return true;

}

transferFrom function always returns True or Throw. It never-ever returns FALSE so checking and negating the transferFrom condition doesn’t make sense most of the cases but IDEX handles 100s of tokens contract and many contracts explicitly returns FALSE if they want to fail the transaction so it makes sense for them to have this condition.

ARAW Token Smart Contract

https://etherscan.io/address/0x30680ac0a8a993088223925265fd7a76beb87e7f#code

function transferFrom(address _from, address _to, uint256 _value)

public

checkAfterICOLock

returns (bool) {

super.transferFrom(_from, _to, _value);

}

Technically this is wrong as it does implicit return false as a missing return from this function but Logically it’s okay as transferFrom either returns True or Throws so code who is calling this method doesn’t require to check the return value — I would admit this was my wrong thinking!

Key Points

For best practice, it’s always good to return True explicitly from transferFrom function

Solidity should not allow implicit return — I would expect language should return Error message when return is not specified explicitly

..So How to Solve this Issue?

Two ways

IDEX update their smart contract to remove the condition which will allow them to support many token contracts that use implicit return as ARAW does.

They may not want to take a RISK as they expect Token Contract to send True or False if Token Contract has some Custom Methods but in that case, based on ERC-20 standard transferFrom should Throw not return False so it’s kind of debate what’s best to follow.

2. ARAW creates a new contract avoiding implicit return False in transferFrom and then do the token swap.

[Update]

After researching and re-thinking; I would agree that ARAW token smart contract needs to be updated as function should always return true or throw based on ERC-20 standard. There are contracts return false when they want to fail the transaction.
Decrypted — AI-powered smart contract creation for non-programmers
Tags: Chronologic, Solidity, Gpt 3, AI, OpenAI

GPT-3, the newest and biggest OpenAI language model that understands the human language, is making headlines worldwide. It has been created by OpenAI, a research business co-founded by Elon Musk, and has been described as the most important and useful advance in AI for years. The software has been pre-trained on hundreds of billions of words, or essentially the entire Internet to understand how languages work.

In a nutshell, GPT-3 is a language prediction model, meaning that it takes a text input by the user and transforms it into poetry, music, social media comments— you name it. And one of the most surprising use cases people found was GPT-3’s ability to code following a natural language prompt. To direct GPT-3 to a specific task, you feed it a simple set of instructions in English of what you hope to achieve and it will ultimately translate it into lines of code.

Code vs. No-code

When writing code, software engineers and blockchain developers may encounter difficulties, for example, code duplication or oversight of specific pieces of the code. Utilizing coding tools controlled by AI technologies, developers can presently avoid making errors when coding. But these tools are much more than assisting with distinguishing basic coding hurdles.

More importantly, GPT-3 can generate whole code lines or even entire functions from plain English, which is the ultimate dream of non-programmers. It allows users to focus less on the coding aspect of their job and more on creativity and innovating in countless ways. No-code category of tools (e.g. WordPress, Wix, and Shopify) make it easier for anyone to build complex applications without programming and use tech otherwise out of their reach.

For its part, ChronoLogic decided to try its hand at developing a no-code software solution that would enable users to write and deploy Solidity contracts on their own rather than hire a blockchain developer. We wanted to democratize smart contract creation even more and put superintelligent AI tech in the hands of regular blockchain users.

Why should you care as a non-programmer? Because it has the potential to revolutionize smart contract creation and this type of tool will likely become available to all.

Decrypted

Decrypted was developed with the goal of blurring the line between creators and developers by making Solidity smart contracts creation as easy as pie.
Uncommon chart types: waffle chart
By: Koen Van Den Eeckhout
Tags: Dataviz, Data, Charts, Data Visualization

If you thought a pie chart was the only food-related chart type out there, think again! There is the donut chart — basically just a pie chart with a hole in the middle — but as a Belgian, I am particularly fond of what’s called a waffle chart. It’s a great alternative to a pie chart, and very easy to make. Oh dear, my stomach’s growling already!

What is a waffle chart?

A waffle chart is basically a square display, usually consisting of 100 smaller squares arranged in a 10-by-10 layout. The squares are colored according to the proportions you are aiming to visualize, similarly to how you would color different slices of a pie chart. As this square layout somewhat resembles a delicious waffle, this immediately explains the name of the chart:

However, compared to a pie chart, a waffle chart is much easier to read — our brain is not well suited to compare different angles and slices, but we can quite easily compare different areas.

Alternative waffle charts

You will notice that many waffle charts are not made up of squares, but of alternative shapes, usually circles. Other shapes, such as small icons, are also possible — in this case we are approaching the realm of pictogram charts.

Another alternative are waffle charts consisting of more (or less) than 100 units, where the items represent actual numbers rather than fractions or percentages:

Here, each square represents $10 million, rather than 1%.

In the latter case, there are some similarities with charts we typically see after elections, showing the distribution of the different seats. One could argue that these kind of charts (‘Parliament charts’) are just a form of ‘warped’ waffle charts:

A Parliament Chart created using Flourish.

Some people prefer to turn their waffle charts by 45°, simply for design purposes, but well, some people are just weird:

Creating waffle charts

Making waffle charts is maybe a little bit tedious, but very simple! For example, you could create square cells in Excel, and color them using intelligent cell formatting to recreate the effect. If you google ‘waffle chart Excel’ you will immediately get hundreds of blog posts and video tutorials describing the necessary steps.

Or you could take your favourite graphics software (such as Paint.NET, GIMP, or Inkscape), draw 100 identical shapes and color them according to your data.

And some people have managed to do it in Infogram, apparently.

More waffles than you’ll ever need

To conclude, some wonderful things people have done with waffle charts, including this tile grid map of waffle charts about internet use in Africa:
The Boston view — On tools, atlases and cages
By: The Visual Agency Editorial
Tags: Dataviz, Information Design, Design History, Charts, Data

A column by Paolo Ciuccarelli

When asked about the most important tools for someone working on data visualization, I often give one of two answers, depending on the context: it’s either “pencil and paper” or “history”. The latter is usually received with more skepticism, being history less obvious as a tool than a pencil. But it’s indeed a very powerful one. No matter what is the questions you are dealing or the insight you are searching for with your dataset, it’s almost certain that someone in the past had a similar issue — and found a solution for it. Unfortunately, history of graphical representation of data is vastly unknown, even if it’s easily and openly accessible through the Web.

One of the online seminars and talks I could attend in these weeks — thankfully not all events are cancelled — was precisely about history and data visualization. Being Michael Friendly and Sandra Rendgen the main speakers, I couldn’t miss it. You can watch it online, so I’ll not write directly about it. I just want to share and recommend here one of the main knowledge sources mentioned in the talk: The David Rumsey Historical Map Collection. It’s a vast archive of maps and statistical atlases produced between the 16th and the 21st century, a resource that it’s worth any spare hours you may be able to gain in these days at home — especially, but not uniquely, if you work on data-related fields.

Mouvement Quinquennal de la Population Francaise par Department depuis 1861 jusqu’ en 1881

Anytime I have the chance to browse the Collection, I’m always impressed by the number of visualizations, charts and visual patterns produced a hundred (and more) of years ago that can be hardly found in any report today and may even look original and innovative to an expert reader. The palette of visual patterns and charts proposed by current visual analytic tools may appear reductive when compared to those atlases. So, here is my point: in the quasi-infinite number of potential graphical transformations we may apply to data, we are framed by the often-narrow array of possibilities offered by the tools we use, being also pencil and paper got forgotten. Without a proper educational scaffolding — the one that designers have, for example — it might be very difficult to imagine something that goes beyond what the tools provide. It doesn’t mean that this is always necessary: those palettes of charts and visual patterns have been carefully designed to address the most common analytical tasks. But that’s not always the case: more nuanced needs are emerging — especially for sharing the results of the analytical processes — and our capacity to produce meaning with data could be caged by the limited amount of meanings that the actual tools propose. Navigating the Rumsey collection can be a good way to overcome those limits and expand our horizon.

Statistical Diagram: Mouvement de la Circulation a L’Interieur de Paris, 1860–1900.

Paolo Ciuccarelli

Center for Design, Northeastern University
Create Barchart in Android Studio
By: Kartik Ganiga
Tags: UI, Android, Charts, Development, Android App Development

I will keep the code simple and let's jump into the coding part.

Setting up build.gradle(Module: app) file

Add the following code in your file.

repositories {

maven { url "https://jitpack.io" }

} dependencies {

//...

//...

implementation 'com.github.PhilJay:MPAndroidChart:v2.2.4'

}

and click on the Sync option which pops up.

Building activity_main.xml file

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:paddingLeft="16dp"

android:paddingTop="16dp"

android:paddingRight="16dp"

android:paddingBottom="16dp"

tools:context="Android.in.barchart.MainActivity">



<com.github.mikephil.charting.charts.BarChart

android:id="@+id/barchart"

android:layout_width="match_parent"

android:layout_height="match_parent" />



</RelativeLayout>

Coding MainActivity.java file

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;



import com.github.mikephil.charting.charts.BarChart;

import com.github.mikephil.charting.data.BarData;

import com.github.mikephil.charting.data.BarDataSet;

import com.github.mikephil.charting.data.BarEntry;

import com.github.mikephil.charting.utils.ColorTemplate;



import java.util.ArrayList;



public class MainActivity extends AppCompatActivity {



@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);



BarChart barChart = (BarChart) findViewById(R.id.barchart);



ArrayList<BarEntry> entries = new ArrayList<>();

entries.add(new BarEntry(8f, 0));

entries.add(new BarEntry(2f, 1));

entries.add(new BarEntry(5f, 2));

entries.add(new BarEntry(20f, 3));

entries.add(new BarEntry(15f, 4));

entries.add(new BarEntry(19f, 5));



BarDataSet bardataset = new BarDataSet(entries, "Cells");



ArrayList<String> labels = new ArrayList<String>();

labels.add("2016");

labels.add("2015");

labels.add("2014");

labels.add("2013");

labels.add("2012");

labels.add("2011");



BarData data = new BarData(labels, bardataset);

barChart.setData(data); // set the data and list of labels into chart

barChart.setDescription("Set Bar Chart Description Here"); // set the description

bardataset.setColors(ColorTemplate.COLORFUL_COLORS);

barChart.animateY(5000);



}

}

Play with entries.add() and labels.add() functions. You will understand how plotting is done.

Basically,

entries.add(new BarEntry(8f, 0);

Here 8f is the value and 0 is the index value which is mapping to

labels.add("2016");

which is at 0th index.

Source and Credits: https://github.com/PhilJay/MPAndroidChart which is A powerful 🚀 Android chart view/graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging and animations.

Clone/Download the repository and play with the code. There is so many chart example available.

Thank You.