Blockchain, smart contracts ... Is it easy or difficult?

In the case of storing information in a database, an attacker can gain access in one way or another and make changes in order to get hold of money.

He does not need to change the entire database, but replace only part of the data stored in the database. In the case of a blockchain, it will be necessary to change the entire block chain with data, which will be extremely difficult to do.

For one reason or another, any changes in the data may occur without malicious intent - a power failure, equipment failure, etc.

How it works?

So, there is data and it needs to be protected from unwanted changes. Information can be anything - money transactions, movement of parcels, plane tickets, etc.

We will divide information (data) into parts (blocks) and build a chain of these blocks.

In our example, data about money transactions will be stored.

Let's create the first block.

Since block is the first, only data and block number will be stored in it.

The data in the block will contain the size of the entire cryptocurrency issue and the number of the first wallet on which they are all at the initial stage.

For clarity, you can create a data array consisting of a hash and a wallet number.

– SHA 256, Β« Β» MD5, ( ), SHA 256.

c4ca4238a0b923820dcc509a6f75849b ( 1).

1 .

( 1) (1, 2, 3, …).

, : 45d04629fc2f54182ba55aad029152ae.

, β„– 1 Β«2Β».

, , , .

.

.

.

, ( ), , .

β€” , , .

-

- ?

( -) .

, 1 ( ) , ( 2), .

( ) , , , 1 , (2) ( , ).

( 1 2) 1 , , , 2 , , .

, , .

, .

( ), , , .

( ) , , .., .

– ( ) , .

PHP code for executing the operation of selling cryptocurrency (ETH) and buying rubles on the exmo.me exchange.

<?php

//exmo.me

$key = 'K-9………';
$secret = 'S-6…………';

$mt = explode(' ', microtime());
$NONCE = $mt[1] . substr($mt[0], 2, 6);

$url = "https://api.exmo.com/v1.1/order_create";

$req = array(
	"nonce"=>$NONCE,
	"pair"=>"ETC_RUB",
	"quantity"=>0.01, //
	"price"=>449.0754, //
	"type"=>"buy",
);

$post_data = http_build_query($req, '', '&');

$sign = hash_hmac('sha512', $post_data, $secret);

$headers = array(
	'Sign: ' . $sign,
	'Key: ' . $key,
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$output = curl_exec($ch);
$output = json_decode($output, true);

echo '<pre>';
var_dump($output);
echo '</pre>';

?>




All Articles