Your Docusaurus site did not load properly.

A very common reason is a wrong site baseUrl configuration.

Current configured baseUrl = / (default value)

We suggest trying baseUrl =

Introduction

Rogue is a secure, flexible and purpose built programming language thats capable of encoding ownership and scarcity of an asset. Rogue has been designed to support a wide range of economic and financial activities of a user on Dijets Blockchain by supporting fundamental conservation properties, not only for built-in currencies, but also for programmer defined assets. In the case of solidity the conservation properties mainly extend to only the built in currency - Ether. This was one of the main reasons for why we chose to build our own language and this choice unlocked a whole new subclass of added functionalities which were not possible before. To begin with, smart contracts provide customizable logic for sending, receiving, storing, and apportioning digital funds that cannot be arbitrarily created, lost, or destroyed.

Furthermore in Rogue the internal balance of an account or , the monetary value inherent in a contract for future payment, or an escrow contract all represent assets that must be conserved in the same ways as any conventional currency would. Thus, smart contracts must be able to implement new assets with expected conservation properties and appropriately control the exchange of one asset for another.

A safe language abstraction for Money#

Rogue can represent money using user-defined linear resource types. And although Rogue has ordinary types e.g. integers and addresses that can be copied, but the resources on the other hand can only be moved and not copied. Exactly how a real world currency operates. Linearity prevents ā€œdouble spendingā€ by moving a resource twice (e.g., into two different callees) and forces a procedure to move all of its resources, avoiding accidental loss.

It's also fully understandable to question the rationale behind Dijets opting for a brand new language rather than sticking with the usual choices. Languages like Solidity are also purpose built for blockchains. So why didn't we at Dijets just go with that. -bottom-10

We explained above the lack of fundamental conservation properties in languages like solidity. To understand its repercussions and importance and why that became the cornerstone for our development of a new language, lets take a simple example of a small contract which demonstrates the advantages of Rogue over Solidity and other contract programming languages where significant problems have already occurred in the past.

pragma solidity ^6.1.4
contract Bank
mapping (address => uint) credit;
function deposit() payable {
amt =
credit[msg.sender] + msg.value
credit[msg.sender] = amt
}
function withdraw() {
uint amt = credit[msg.sender];
msg.sender.transfer(amt);
credit[msg.sender] = 0;
}

The contract above implements a relatively simple savings bank contract with the following requirements: ā€¢ A customer should be able to deposit money worth N via the deposit procedure and subsequently extract money worth N via the withdraw procedure. ā€¢ No customer should be able to withdraw money deposited by another customer

A smart contract like this implements bidirectional exchanges of the languageā€™s native currency for a bank credit currency also defined in the contract. Notice that in Solidity's case (contract code above) both native and custom currencies are nowhere to be found except being represented indirectly via maps of identities to integers.

Let's take a look at the same contract and how it can be written in Rogue but without the need to represent currencies indirectly and or via maps of their identities to integers. Currency in Rogue, is represented exactly as it ought to - Currency.

method Bank
use 0x0::Coin;
resource T { balance: Coin::T }
resource Credit { amt: u64, bank: address }
func deposit(
coin: Coin::T,
bank: address
): Credit {
let amt = Coin::value(&coin);
let t = borrow_global<T>(copy bank);
Coin::deposit(&mut t.balance, move coin);
return Credit {
amt: move amt, bank: move bank
};
}
func withdraw(credit: Credit): Coin::T {
Credit { amt, bank } = move credit;
let t = borrow_global<T>(move bank);
return Coin::withdraw(
&mut t.balance, move amt
);
}

Rogue represents money/currency using user-defined linear resource types. Rogues has the ordinary types like integers and addresses too and those can be copied, but resources in Rogue can't be copied. They can only be moved or destroyed or go out of scope of a variable to completely cease to exist. Linearity prevents ā€œdouble spendingā€ by moving a resource twice (e.g., into two different callees) and forces a well-typed procedure to move all of its resources, avoiding accidental loss.

In this guide you will get to grips with the fundamentals of Rogue and methods. Whilst every effort has been made to provide up-to-date and versioned information, please note that Rogue is still a new language and some major changes in the near future are to be expected.

Describing Rogue#

Rogue is a new high level, secure and next generation language intended for smart contracts development. Rogue has been built specifically for Dijets and provides the foundation for the implementation of Dijets Blockchain principles. It is an executable bytecode language used to implement custom transactions and 'Methods' (type of smart contracts) in Dijets. The key feature of Rogue is the ability to define custom resource types (an iterative take on the semantics of the Linear Logic). The quickest way to understand a resource is to consider it as something that can never be copied or implicitly discarded, only moved between different program storage locations.