mobileRumblefishLogo
Menu
desktopRumblefishLogo
Services
Products
Case studies
Careers
Resources
About us
Solidity and smart contracts: an overview

Solidity and smart contracts: an overview

Fri, Mar 19, 20214 min read

Category: Code Stories / Blockchain

Developers looking to write Ethereum smart contracts can now choose from several options. One of them is Solidity, a JavaScript-based language recommended for this purpose nowadays.

What is Solidity and how does it help with writing smart contracts? Read this article to get the answer.

Introducing Solidity

Solidity is an object-oriented, high-level programming language designed to target the Ethereum Virtual Machine (EVM). It manages the behavior of accounts within the Ethereum state. This makes Solidity a good technology choice for implementing smart contracts. It’s basically a contract-oriented language.

By using Solidity, you can develop contracts for a wide range of uses - from crowdfunding and blind auctions to voting and multi-signature wallets. 

Let’s pause at smart contracts for a moment

What exactly are smart contracts? They’re computer programs or transaction protocols designed to automatically execute, control, or document specific events and actions in line with the terms of a contract or agreement.

It’s thanks to smart contracts that blockchain applications are programmable and can go beyond currency transfers. In short, smart contracts automate the process of verifying the terms of the agreement. Any operation that depends on a condition can be carried out without involving any middleman or third parties, saving time and money.

Smart contracts are fully transparent and accessible to all the relevant parties. The contracts live on the internet and run on software code, which helps to accelerate the speed of transaction verification.  

Smart contracts and Solidity

The approach behind Solidity, called “design by contract,” is nothing new. It was created by Bertrand Meyer in 1986, while he was working on the Eiffel programming language. The idea was to encourage developers to define formal specifications (preconditions, postconditions, and invariants) for each software component.

In Solidity, these specifications are called contracts. They can be instantiated and have constructors, global and local variables, private and public methods. Solidity contracts also come with public addresses in the blockchain (after they’re deployed). They can also store and send value.

Moreover, Solidity operates on the account-based model. Just to give you an example (mind you, it’s a specific one): This might mean that operations on a contract result in changes applied to the properties and holdings of the underlying accounts, as the contract itself is alive. 

How Solidity helps developers write smart contracts 

1. Granular privacy

As I mentioned before, a single Solidity contract holds various account holdings. Actions may change the holdings of every account, and the holdings are visible to everyone because Solidity was designed for public Ethereum (where every transaction needs to be validated by the network). So, when Solidity runs on a permissioned platform (say, Quorum), you need specific constructs matching the platform to enforce the updated privacy model.

contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping (address => uint256) private _balances;
    mapping (address => mapping (address => uint256)) private _allowances;
    uint256 private _totalSupply;
    string private _name;
    string private _symbol;
    constructor (string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }
    function name() public view virtual override returns (string memory) {
        return _name;
    }

2. Large community and ecosystem of tools

Developers get support from many tools in Solidity’s large, open ecosystem. An example is Remix, a handy open-source tool that makes it possible to write Solidity contracts straight from the browser, without having to install anything. It’s great for creating small and quick projects. On top of that, these Solidity tools enable interaction with testnet - in fact, you can test your processes on a live public testnet.

The community that surrounds Solidity is very large, so getting support for your development project is easy. It’s very likely that someone out there has already solved the problem you’re facing.

3. Portability and interoperability

Another perk of Solidity is that it supports portability. Portability means that a smart contract can run as-is on multiple ledgers. When it comes to portability, Solidity uses the Ethereum Virtual Machine (EVM) that you can integrate to run on multiple ledgers.

Conclusion

Solidity is a language purpose-built for smart contracts, and its simplicity only makes it a better candidate for writing applications based on smart contracts.  

Personally, I think the future lies in languages that compile to WebAssembly. Ethereum itself will probably support it someday. Then the contracts can be written in, for example, C ++ or Rust, and developers have a lot of general-purpose libraries at their disposal. In Solidity, you often can’t even do a simple thing unless you write it yourself.

We hope that this article clarifies why Solidity is such a great technology choice for writing smart contracts. 

If you have experience with Solidity and are looking for an interesting project, we might have something for you. Get in touch with us to learn more.

Sylwia Bień-Chudarek
Sylwia Bień-Chudarek

Head of Growth

Categories
Follow Us
AnimatedLogoTextImageAnimatedLogoFishesImage
RUMBLEFISH POLAND SP Z O.O.Filipa Eisenberga 11/3 31-523 Kraków, Polska
NIP: 6772425725REGON: 368368380KRS: 0000696628
P: +48 601 265 364E: hello@rumblefish.dev
Copyright © 2024 Rumblefish