понедельник, 20 мая 2024 г.

Blockchain tools

0. Solidity Documentation Generator









solc --ast-compact-json contract.sol


The second feature, but no less important, is significant cost savings. The entire Merkle tree requires only one token worth 25 cents. And all other information is stored in the client’s storage.

 1. ChainIDE

ChainIDE и RemixIDE are both cloud-based development environments for Solidity. However, ChainIDE supports many blockchain platforms, making it more flexible.

2. ChainList

ChainList is a resource that provides a convenient means to interact with various blockchain networks on Ethereum..

3. Tenderly

Tenderly is a powerful platform for monitoring and debugging smart contracts on Ethereum and more

4. Ethereum Security Toolbox

All this was invented so that at some point even the developers themselves would not be able to change the source code of contracts/programs/business logic on Merkle trees.

5. MythX

MythX is a security testing service for Ethereum smart contracts that performs comprehensive security analysis, detecting vulnerabilities early in development.

6. Foundry

Foundry is a tool for developing blockchain projects built in Rust. Rust is a really great programming language that is becoming increasingly popular on blockchain platforms like Polkadot and Solana. - https://habr.com/ru/articles/756542/

https://habr.com/ru/articles/766078/

7. Evm.codes

EVM-Codes is a handy resource that provides a complete list of Ethereum Virtual Machine (EVM) operations (opcodes) with detailed descriptions of their functionality.

8. Openchain

OpenChain is a library that provides 3 cool tools: an ABI tool, a transaction tracer, and a library of unknown selectors.

9. OpenZeppelin Defender

OpenZeppelin Defender is a platform for managing and automating operations with smart contracts on the Ethereum blockchain.

10. Ethereum Tipper

Ethereum Tipper is a simple widget for developers to get tips.

11. Gelato Network

Gelato Network is an automated system that allows users and developers to set up conditions for automatic transactions on the Ethereum blockchain.

12. Cookbook Dev

Cookbook is a completely free and open source registry of different smart contracts.

13. OSWAR

OSWAR is an encyclopedia of all types of attacks and hacks on blockchain projects, smart contracts and infrastructures.

14. Builder0x69 JSON-RPC API

Builder0x69 is a free MEV Blocker RPC endpoint that will help you hide your transactions from MEV bots. In short, MEV (Miner Extractable Value) bots are programs that try to extract maximum value from blockchain transactions.

15. EtherMail

EtherMail is a service that allows you to send messages to recipients on Ethereum using their Ethereum addresses instead of traditional email addresses.

16. BUIDLer by Etherspot

Buidler by Etherspot is a tool that provides account abstraction functionality (EIP-4337) on the Ethereum network

17. Blocktorch

Blocktorch is a multi-chain platform for real-time analysis of your contracts.

18. Moralis

 Moralis is a decentralized application (dApps) development platform that provides a wide range of features.

19. Perigord - a tool similar to Truffle, using Go instead of JavaScript.

https://habr.com/ru/companies/pt/articles/735756/


Infura

 Infura - The logo is similar to Inkan 

<path fill-rule="evenodd" clip-rule="evenodd" d="M0.579857 1.71289V4.24601L6.71224 3.62323H8.97567V7.72394L5.16434 8.87439L0 10.104L0.766682 12.5808L5.71566 10.7045L8.97567 9.72089V16.453H6.71224L0.579857 15.8292V18.3628H19.3076V15.8292L13.1752 16.453H10.9112V9.72089L14.1551 10.6992L19.1208 12.5808L19.8874 10.104L14.7366 8.87811L10.9112 7.72394V3.62323H13.1752L19.3076 4.24601V1.71289H0.579857Z" fill="#FF5833"></path>


Good for crafting in Minecraft

Common vulnerabilities on L1 are overconsumption of gas, multiple calls to counterparties' payments without verification, price pumping in a 15-second interval, various loops and long waits. Merkle trees are according to any L2, but we can also use our memory. And return values through Oracle (that’s what they call call-back sockets)


(Because there are so many complexities in distributed contracts that without formal verification, you can create something without errors only in such a visual language.)

The above technologies are good for crafting in Minecraft, but bad for real production.


In automated production, for objective reasons (due to the large number of products), they use the most inexpensive and easy-to-manufacture chip. It should only have a couple of functions. Supporting a critical channel to the Internet and performing business functions on bare metal.

The Internet will be at frequencies close to 10 Megahertz. Which imposes physical limitations on chip technology.


By the way, when it was necessary to make a non-changeable program, it was simply stitched onto the switch matrix. It was called microcode. In the future, such firmware will be based on ternary logic on a memristor matrix on the Galia Arsenide. They will be stitched with a laser. A prototype of a chip with a RISK-V core has already been released in Israel last year.


Of the shortcomings. It is worth mentioning races (ambiguity in time) and confusion with the owners (ambiguity in space). To avoid these problems, the tree must be built according to a clear rule, where the levels of coordination in time alternated strictly with the levels of coordination in space. And their combination was strictly responsible for one type of environment (or resources).


Well, from a hardware point of view, it’s not the right choice for a computing machine. I recommend the FPGA (62 Euro with case) and silicon ABC compiler for a complete product. There is a cheaper option 6502 (38 Euro with case).


An alternative is to create your own implementation based on the 6502 assembler. Because it requires minimal hardware. You can implement the entire project in the ABC flint compiler and save the tree of operations in the form of a Merkle tree or in a chain. Then our assembler programs will be evidence. We won't need to seal them. In addition, it will be possible to certify specialists.


Disadvantages - this is a rather costly event in terms of money and time.


Advantages - our contracts will not be vulnerable and will not be limited in terms of computing features.


Summary - The current state of affairs around contracts is a fuss of mice. We haven't focused on these technologies for 10 years. Perhaps it's time to clean up the mess.


DRAKON (With FSM) editor

 

and Kaa editor and SQLite3 and asm 6502.

Because you can’t trust anyone in matters involving huge risks. And an open source survey, in which each package changes, will require many times more resources than maintaining a minimal, but unique set with advanced functions that no one else has.

In addition, Kaa is a terminal application and it works from any server, including the Terminal application for Android starting with 9 CyanagenMod


Access to publicly accessible memory for 15 seconds to a minute is only for agents storing a rule or hash. This will help avoid abuse by miners and mediators. 


In BBC Micro 6502 a rider was provided. And due to memory timings and technology limitations, more than 2 chips could not work with it at once. Since the overall program cycle had to be less than the memory update time. So that the synchronous mode of operation does not require the additional cost of an asynchronous state machine. This also solved problems with races in memory.


Below is a diagram of a Random Number Generator (RND) from the 6502 processor. Actually in cryptography and password coding, this is still the most important and often predictable part in terms of probabilities.

Even if we listen to white noise from the air, attackers can easily falsify white noise through the means of Radio-Electronic Warfare.

In order not to deviate too far from the topic, we will not recall the technologies of the Caucasian-African Cathars during the Crusades in Palestine.

This circuit was generated using Applicon software, which is now called VLSI Electric. I am part of the development team of this American SoftWare as a tester. Since 2000, rewritten in JAVA. 


This made it possible not only to make casino slot machines, but also to shoot down a battleship with a missile during the Argentine-British War for the Falkland Islands. 


I'm not hinting at anything. Especially the leaking of the illegal dialogue of the Luftwaffe bosses last week. But the rocket was French, but the chip was English. And the fascists of Argentina were fools. Although at that time the former Germans were in Argentina in the army.





Federated Node Provisioning

 

Federated Node Provisioning

Production

Here are the recommendations and/or requirements when setting up a production-grade Counterblock Federated Node:

Server Hardware/Network Recommendations:

  • Xeon E3+ or similar-class processor

  • 16GB+ RAM (ECC)

  • Disk drives in RAID-1 (mirrored) configuration (SSD prefered)

  • Hosted in a secure data center with physical security and access controls

  • DDOS protection recommended if you will be offering your service to others

** Disk Space Requirements ** The exact disk space required will be dependent on what services are run on the node:

* Base System: **20GB** (to be safe)

* ``counterpartyd``, ``counterblockd`` databases: **~200MB**

* ``insight``: **~30GB** (mainnet), **~3GB** (testnet)

* ``armory_utxsvr``: **~25GB** (mainnet), **~3GB** (testnet)


Generally, we recommend building on a server with at least 120GB of available disk space.


User Configuration

Note that when you set up a federated node, the script creates two new users on the system: xcp and xcpd. (The xcp user also has an xcp group created for it as well.)

The script installs counterpartyd, counterwallet, etc into the home directory of the xcp user. This user also owns all installed files. However, the daemons (i.e. bitcoind, insight, counterpartyd, counterblockd, and nginx) are actually run as the xcpd user, which has no write access to the files such as the counterwallet and counterpartyd source code files. The reason things are set up like this is so that even if there is a horrible bug in one of the products that allows for a RCE (or Remote Control Exploit), where the attacker would essentially be able to gain the ability to execute commands on the system as that user, two things should prevent this:

  • The xcpd user doesn't actually have write access to any sensitive files on the server (beyond the log and database files for bitcoind, counterpartyd, etc.)

  • The xcpd user uses /bin/false as its shell, which prevents the attacker from gaining shell-level access

This setup is such to minimize (and hopefully eliminate) the impact from any kind of potential system-level exploit.



sudo python3 setup_federated_node.py



We skip installing the NodeJS version, since the repository is outdated.

From this link we take the old Bitcoin daemon.


https://bitcoin.org/bin/insecure/bitcoin-core-0.9.2.1/


The 0.9.0 release of Bitcoin Core added a new standard transaction type granting access to a previously disallowed script function, OP_RETURN. This function accepts a user-defined sequence of up to 40 bytes. When a transaction containing a challenge script with an OP_RETURN function is mined into a block, the accompanying byte sequence enters the block chain.






Changes in Counterpartyd_build setup_federated_node.py



sudo rm /etc/apt/sources.list.d/mongodb*.list


sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927



echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list


 sudo apt-get update



>>Reading package lists... Done

>>W: GPG error: http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 >>Release: The following signatures couldn't be verified because the public key >>is not available: NO_PUBKEY D68FA50FEA312927

>>E: The repository 'http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 >>Release' is not signed.

>>N: Updating from such a repository can't be done securely, and is therefore >>disabled by default.

>>N: See apt-secure(8) manpage for repository creation and user configuration >>details.


apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv D68FA50FEA312927


>>gpg: key D68FA50FEA312927: public key "MongoDB 3.2 Release Signing Key >><packaging@mongodb.com>" imported

>>gpg: Total number processed: 1

>>gpg:               imported: 1



sudo apt-get update

sudo apt install mongodb-org



cd ¬/counterpartyd_build


sudo python3 setup.py --with-counterblockd



Commits on Mar 6, 2024 mongodb v 3.2.22


https://github.com/Ignat99/counterpartyd_build/commit/eb8662eb6bd7676decb7cbebf6f5920ea880c2d4



Error during the package build process Сounterblockd



Running setup.py install for gevent ... error

2024-03-06 14:09:48,939|ERROR: Command failed: '/home/user/counterpartyd_build/env.counterblockd/bin/pip install -r /home/user/counterpartyd_build/dist/counterblockd/pip-requirements.txt'

including stdio.h and sys/types.h.


https://github.com/gevent/gevent/commit/3ab69f263dcf9e3b59d8ab7e6bd0b8e521fea771




/* CARES_PULL_SYS_TYPES_H is defined above when inclusion of header file  */

/* sys/types.h is required here to properly make type definitions below.  */

#ifdef CARES_PULL_SYS_TYPES_H

#  include <sys/types.h>

#endif



The problem was solved by moving to the next version 1.2.0. It's all about this piece of code. This piece of code is compiled by Cython. The scripting language is translated into C and then assembled. This was how performance was achieved before Rust was invented.

https://github.com/Ignat99/counterblockd/commit/dfb273ae3de26ffc748d051252fd5972fc9b0df5


Some issue with old python pytest related packages:



ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.

pytest-cov 2.11.1 requires pytest>=4.6, but you have pytest 2.5.1 which is incompatible.

tweepy 3.10.0 requires requests[socks]>=2.11.1, but you have requests 2.3.0 which is incompatible.

passnfly 0.1.1 requires Flask~=1.1.2, but you have flask 0.10.1 which is incompatible.



Change version and server of NodeJS


https://www.ubuntuupdates.org/ppa/nodejs_10.x



  1. Commit nodejs https://github.com/Ignat99/counterpartyd_build/commit/acf5bba9de9b21f993600b558d9fca42ca33c9cd


  1. Change version insight-api 0.3.1 and NodeJS to 13.14.0 (Possible up to 18.x with old bitcoin backend) https://github.com/Ignat99/counterpartyd_build/commit/f2ebb7504ab72b718606c70f92b2895c851c33b4



Nginx issue

An outdated web server is used here. The main disadvantage of all these solutions is the old SSL. There was vulnerability in him. But you can turn this disadvantage into an advantage by replacing the block stream cipher in closed networks with your own. In any case, you will need to do a survey of ALL free and open source packages.


E: Unable to locate package nginx-openresty

2024-03-08 11:26:01,798|ERROR: Command failed: 'apt-get -y remove nginx-openresty'

https://web.archive.org/web/20130709201900/http://brian.akins.org/blog/2013/03/19/building-openresty-on-ubuntu/

https://openresty.org/en/

https://groups.google.com/g/openresty-en?pli=1


OpenResty® is a full-fledged web platform that integrates our enhanced version of the Nginx core, our enhanced version of LuaJIT, many carefully written Lua libraries, lots of high quality 3rd-party Nginx modules, and most of their external dependencies. It is designed to help developers easily build scalable web applications, web services, and dynamic web gateways.




wget http://openresty.org/download/ngx_openresty-1.2.6.6.tar.gz

tar -zxvf ngx_openresty-1.2.6.6.tar.gz

cd ngx_openresty-1.2.6.6

https://github.com/Ignat99/counterpartyd_build/commit/58fff8fc51157578f07789d1d0c8e4f07db5d7a9



W: GPG error: https://apt.newrelic.com/debian newrelic Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B31B29E5548C16BF

E: The repository 'http://apt.newrelic.com/debian newrelic Release' is not signed.

This company even offered me a job after a seminar in Barcelona. The licenses and their agent versions are already outdated. Now all the functions of their product such as Server Dashboard can be assembled quite quickly from free and open source software.


Error of JSON with version Blockchain



Traceback (most recent call last):

  File "/home/xcp/counterpartyd_build/env/lib/python3.6/site-packages/requests/adapters.py", line 327, in send

    timeout=timeout

  File "/home/xcp/counterpartyd_build/env/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 520, in urlopen

    raise SSLError(e)

requests.packages.urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)


During handling of the above exception, another exception occurred:



Fix:


https://raw.githubusercontent.com/Ignat99/counterpartyd/master/version.json


Problem connect to bitcoind


Traceback (most recent call last):

  File "/home/xcp/counterpartyd_build/dist/counterpartyd/counterpartyd.py", line 1132, in <module>

    blocks.follow(db)

  File "/home/xcp/counterpartyd_build/dist/counterpartyd/lib/blocks.py", line 1292, in follow

    block_count = bitcoin.get_block_count()

  File "/home/xcp/counterpartyd_build/dist/counterpartyd/lib/bitcoin.py", line 77, in get_block_count

    return int(rpc('getblockcount', []))

  File "/home/xcp/counterpartyd_build/dist/counterpartyd/lib/bitcoin.py", line 165, in rpc

    raise exceptions.BitcoindRPCError('Cannot communicate with {} Core. ({} is set to run on {}, is {} Core?)'.format(config.BTC_NAME, config.XCP_CLIENT, network, config.BTC_NAME))

lib.exceptions.BitcoindRPCError: Cannot communicate with Bitcoin Core. (counterpartyd is set to run on mainnet, is Bitcoin Core?)



Listen http server RPC problem

New form of BLOCK_FIRST_TESTNET

Fix: add tx_info in txlist_hash, merge new_consensus_checks, fix config and previous merge, continue instead exception


Counterpartyd interfaces


user@ign:~/counterpartyd_build$ sudo su -s /bin/bash -c 'counterpartyd --data-dir=/home/xcp/.config/counterpartyd-testnet --testnet' xcpd

Status: Connecting to database.

Status: Running v9.45.0 of counterpartyd.

usage: counterpartyd [-h] [-V] [-v] [--testnet] [--testcoin]

                     [--carefulness CAREFULNESS] [--unconfirmed]

                     [--encoding ENCODING] [--fee-per-kb FEE_PER_KB]

                     [--regular-dust-size REGULAR_DUST_SIZE]

                     [--multisig-dust-size MULTISIG_DUST_SIZE]

                     [--op-return-value OP_RETURN_VALUE] [--unsigned]

                     [--data-dir DATA_DIR] [--database-file DATABASE_FILE]

                     [--config-file CONFIG_FILE] [--log-file LOG_FILE]

                     [--backend-rpc-connect BACKEND_RPC_CONNECT]

                     [--backend-rpc-port BACKEND_RPC_PORT]

                     [--backend-rpc-user BACKEND_RPC_USER]

                     [--backend-rpc-password BACKEND_RPC_PASSWORD]

                     [--backend-rpc-ssl] [--backend-rpc-ssl-verify]

                     [--blockchain-service-name BLOCKCHAIN_SERVICE_NAME]

                     [--blockchain-service-connect BLOCKCHAIN_SERVICE_CONNECT]

                     [--rpc-host RPC_HOST] [--rpc-port RPC_PORT]

                     [--rpc-user RPC_USER] [--rpc-password RPC_PASSWORD]

                     [--rpc-allow-cors]

                     {server,send,order,btcpay,issuance,broadcast,bet,dividend,burn,cancel,callback,rps,rpsresolve,publish,balances,asset,wallet,pending,reparse,rollback,market}

                     ...


the reference implementation of the Counterparty protocol

positional arguments:

  {server,send,order,btcpay,issuance,broadcast,bet,dividend,burn,cancel,callback,rps,rpsresolve,publish,balances,asset,wallet,pending,reparse,rollback,market}

                        the action to be taken

    server              run the server

    send                create and broadcast a *send* message

    order               create and broadcast an *order* message

    btcpay              create and broadcast a *BTCpay* message, to settle an

                        Order Match for which you owe BTC

    issuance            issue a new asset, issue more of an existing asset or

                        transfer the ownership of an asset

    broadcast           broadcast textual and numerical information to the

                        network

    bet                 offer to make a bet on the value of a feed

    dividend            pay dividends to the holders of an asset (in

                        proportion to their stake in it)

    burn                destroy {} to earn XCP, during an initial period of

                        time

    cancel              cancel an open order or bet you created

    callback            callback a fraction of an asset

    rps                 open a rock-paper-scissors like game

    rpsresolve          resolve a rock-paper-scissors like game

    publish             publish arbitrary data in the blockchain

    balances            display the balances of a Counterparty address

    asset               display the basic properties of a Counterparty asset

    wallet              list the addresses in your backend wallet along with

                        their balances in all Counterparty assets

    pending             list pending order matches awaiting BTCpayment from

                        you

    reparse             reparse all transactions in the database

    rollback            rollback database

    market              fill the screen with an always up-to-date summary of

                        the Counterparty market

optional arguments:

  -h, --help            show this help message and exit

  -V, --version         show program's version number and exit

  -v, --verbose         sets log level to DEBUG instead of WARNING

  --testnet             use Bitcoin testnet addresses and block numbers

  --testcoin            use the test Counterparty network on every blockchain

  --carefulness CAREFULNESS

                        check conservation of assets after every CAREFULNESS

                        transactions (potentially slow)

  --unconfirmed         allow the spending of unconfirmed transaction outputs

  --encoding ENCODING   data encoding method

  --fee-per-kb FEE_PER_KB

                        fee per kilobyte, in BTC

  --regular-dust-size REGULAR_DUST_SIZE

                        value for dust Pay‐to‐Pubkey‐Hash outputs, in BTC

  --multisig-dust-size MULTISIG_DUST_SIZE

                        for dust OP_CHECKMULTISIG outputs, in BTC

  --op-return-value OP_RETURN_VALUE

                        value for OP_RETURN outputs, in BTC

  --unsigned            print out unsigned hex of transaction; do not sign or

                        broadcast

  --data-dir DATA_DIR   the directory in which to keep the database, config

                        file and log file, by default

  --database-file DATABASE_FILE

                        the location of the SQLite3 database

  --config-file CONFIG_FILE

                        the location of the configuration file

  --log-file LOG_FILE   the location of the log file

  --backend-rpc-connect BACKEND_RPC_CONNECT

                        the hostname or IP of the backend bitcoind JSON-RPC

                        server

  --backend-rpc-port BACKEND_RPC_PORT

                        the backend JSON-RPC port to connect to

  --backend-rpc-user BACKEND_RPC_USER

                        the username used to communicate with backend over

                        JSON-RPC

  --backend-rpc-password BACKEND_RPC_PASSWORD

                        the password used to communicate with backend over

                        JSON-RPC

  --backend-rpc-ssl     use SSL to connect to backend (default: false)

  --backend-rpc-ssl-verify

                        verify SSL certificate of backend; disallow use of

                        self‐signed certificates (default: false)

  --blockchain-service-name BLOCKCHAIN_SERVICE_NAME

                        the blockchain service name to connect to

  --blockchain-service-connect BLOCKCHAIN_SERVICE_CONNECT

                        the blockchain service server URL base to connect to,

                        if not default

  --rpc-host RPC_HOST   the IP of the interface to bind to for providing JSON-

                        RPC API access (0.0.0.0 for all interfaces)

  --rpc-port RPC_PORT   port on which to provide the counterpartyd JSON-RPC

                        API

  --rpc-user RPC_USER   required username to use the counterpartyd JSON-RPC

                        API (via HTTP basic auth)

  --rpc-password RPC_PASSWORD

                        required password (for rpc-user) to use the

                        counterpartyd JSON-RPC API (via HTTP basic auth)

  --rpc-allow-cors      Allow ajax cross domain request



The configuration we are checking:

sudo python3 setup_federated_node.py


2024-03-06 16:35:12,944|DEBUG: answered_questions: {'op': 'r', 'role': 'counterpartyd_only', 'branch': 'feature', 'run_mode': 't', 'backend_rpc_mode': 'b', 'blockchain_service': 'i', 'counterpartyd_public': 'y', 'counterwallet_support_email': None, 'security_hardening': 'n', 'autostart_services': 'y'}


Successfully launched service


2024-03-08 12:24:24,753|INFO: Counterblock Federated Node Build Complete (whew).

2024-03-08 12:24:24,754|DEBUG: RUNNING COMMAND: rm -f /etc/service/bitcoind-testnet/down

2024-03-08 12:24:24,759|DEBUG: RUNNING COMMAND: rm -f /etc/service/insight-testnet/down

2024-03-08 12:24:24,763|DEBUG: RUNNING COMMAND: rm -f /etc/service/counterpartyd-testnet/down

2024-03-08 12:24:24,767|DEBUG: RUNNING COMMAND: rm -f /etc/service/counterblockd/down

2024-03-08 12:24:24,770|DEBUG: RUNNING COMMAND: rm -f /etc/service/counterblockd-testnet/down


Starting the system

Start the bitcoind


sudo sv start bitcoind

sudo sv start bitcoind-testnet


sudo tail -f ~xcp/.bitcoin/debug.log

sudo tail -f ~xcp/.bitcoin-testnet/testnet3/debug.log

sudo sv start insight

sudo sv start insight-testnet


sudo tail -f ~xcp/insight-api/log/current

sudo tail -f ~xcp/insight-api/log-testnet/current

Then, watching these logs, wait for the insight sync (as well as the bitcoind sync and counterpartyd syncs) to finish, which should take between 7 and 12 hours. After this is all done, reboot the box for the new services to start (which includes both counterpartyd and counterblockd).

counterblockd, after starting up must then sync to counterpartyd. It will do this automatically, and the process will take between 20 minutes to 1 hour most likely. You can check on the status of counterblockd's sync using:



sudo tail -f ~xcp/.config/counterblockd/counterblockd.log

sudo tail -f ~xcp/.config/counterblockd-testnet/counterblockd.log

Also, you can start up the daemons in the foreground, for easier debugging, using the following sets of commands:


#bitcoind

sudo su -s /bin/bash -c 'bitcoind -datadir=/home/xcp/.bitcoin' xcpd

sudo su -s /bin/bash -c 'bitcoind -datadir=/home/xcp/.bitcoin-testnet' xcpd


#counterpartyd & counterblockd mainnet

sudo su -s /bin/bash -c 'counterpartyd --data-dir=/home/xcp/.config/counterpartyd' xcpd

sudo su -s /bin/bash -c 'counterblockd --data-dir=/home/xcp/.config/counterblockd -v' xcpd


#counterpartyd & counterblockd testnet

sudo su -s /bin/bash -c 'counterpartyd --data-dir=/home/xcp/.config/counterpartyd-testnet --testnet' xcpd

sudo su -s /bin/bash -c 'counterblockd --data-dir=/home/xcp/.config/counterblockd-testnet --testnet -v' xcpd


Start the Counterpartyd


sudo sv start counterpartyd

sudo sv start counterpartyd-testnet


sudo tail -f ~xcp/.config/counterpartyd/counterpartyd.log

sudo tail -f ~xcp/.config/counterpartyd-testnet/counterpartyd.testnet.log



Counterparty testnet  faucet


Start wallet.

Bitcoin testnet3 faucet

Compatibility with Ethereum's Smart Contracts

https://github.com/CounterpartyXCP/counterparty-core/blob/9.52.0/counterpartylib/test/contracts_test.py


"""

This module tests for compability with Ethereum's Smart Contracts.

"""


https://github.com/CounterpartyXCP/counterparty-core/blob/v9.49.4rc3/counterpartylib/test/contracts_test.py


15/Jan/2015

v9.49.4rc3


This is an example of a smart contract and a link to the first mention and version number counterpartyd.


rename contracts_test, only new OP_RETURN data are obfuscated, fixes + update testnet checkpoints


Transaction Encodings

In the general Bitcoin protocol, the parameter OP_RETURN was only 40 bytes long.


By default the default value of the encoding parameter detailed above is auto, which means that counterparty-server automatically determines the best way to encode the Counterparty protol data into a new tranaction. If you know what you are doing and would like to explicitly specify an encoding:

  • To return the transaction as an OP_RETURN transaction, specify opreturn for the encoding parameter.

  • OP_RETURN transactions cannot have more than 80 bytes of data. If you force OP_RETURN encoding and your transaction would have more than this amount, an exception will be generated.

  • To return the transaction as a multisig transaction, specify multisig for the encoding parameter.

    • pubkey should be set to the hex-encoded public key of the source address.

    • Note that with the newest versions of Bitcoin (0.12.1 onward), bare multisig encoding does not reliably propagate. More information on this is documented here.

  • To return the transaction as a pubkeyhash transaction, specify pubkeyhash for the encoding parameter.

    • pubkey should be set to the hex-encoded public key of the source address.


Advanced create_ parameters

Create_bet

Create_broadcast

Create_btcpay

Create_burn

Create_cancel

Create_dividend

Create_issuance

Create_order

Create_send


Each create_ call detailed below can take the following common keyword parameters:

  • encoding (string): The encoding method to use, see transaction encodings for more info.

  • pubkey (string/list): The hexadecimal public key of the source address (or a list of the keys, if multi‐sig). Required when using encoding parameter values of multisig or pubkeyhash. See transactions encoding for more info

  • allow_unconfirmed_inputs (boolean): Set to true to allow this transaction to utilize unconfirmed UTXOs as inputs. Defaults to false.

  • fee (integer): If you’d like to specify a custom miners’ fee, specify it here (in satoshi). Leave as default for the server to automatically choose.

  • fee_per_kb (integer): The fee per kilobyte of transaction data constant that the server uses when deciding on the dynamic fee to use (in satoshi).

  • fee_provided (integer): If you would like to specify a maximum fee (up to and including which may be used as the transaction fee), specify it here (in satoshi). This differs from fee in that this is an upper bound value, which fee is an exact value.

  • custom_inputs (list): Use only these specific UTXOs as inputs for the transaction being created. If specified, this parameter is a list of (JSON-encoded) UTXO objects (token), whose properties match those as retrieved by listunspent function from bitcoind (e.g. see here). Note that the actual UTXOs used may be a subset of this list.

  • unspent_tx_hash (string): When compiling the UTXOs to use as inputs for the transaction being created, only consider unspent outputs from this specific transaction hash. Defaults to null to consider all UTXOs for the address. Do not use this parameter if you are specifying custom_inputs.

  • regular_dust_size (integer): Specify (in satoshi) to override the (dust) amount of BTC used for each non-(bare) multisig output. Defaults to 5430 satoshi.

  • multisig_dust_size (integer): Specify (in satoshi) to override the (dust) amount of BTC used for each (bare) multisig output. Defaults to 7800 satoshi.

  • dust_return_pubkey (string): The dust return pubkey is used in multi-sig data outputs (as the only real pubkey) to make those the outputs spendable. By default, this pubkey is taken from the pubkey used in the first transaction input. However, it can be overridden here (and is required to be specified if a P2SH input is used and multisig is used as the data output encoding.) If specified, specify the public key (in hex format) where dust will be returned to so that it can be reclaimed. Only valid/useful when used with transactions that utilize multisig data encoding. Note that if this valis is set to false, this instructs counterparty-server to use the default dust return pubkey configured at the node level. If this default is not set at the node level, the call will generate an exception.

  • disable_utxo_locks (boolean): By default, UTXO’s utilized when creating a transaction are “locked” for a few seconds, to prevent a case where rapidly generating create_ calls reuse UTXOs due to their spent status not being updated in bitcoind yet. Specify true for this parameter to disable this behavior, and not temporarily lock UTXOs.

  • op_return_value (integer): The value (in satoshis) to use with any OP_RETURN outputs in the generated transaction. Defaults to 0. Don’t use this, unless you like throwing your money away.

With the exception of pubkey and allow_unconfirmed_inputs, these values should be left at their defaults, unless you know what you are doing.

Example code for creating a contract


In much the same way, we can place image hashes and even functional code in the Fort/Serpent/РАЯ style on the blockchain


DSSP - interactive structured programming system

The basic language of DSSP is the Developing Adaptive Language (RAYA)

(ДССП — диалоговая система структурированного программирования

Базовый язык ДССП — Развиваемый Адаптивный Язык (РАЯ) )


Brusentsov, the creator of the “Setun”  ternary computer and language Developing Adaptive Language (RAYA), talked to me on the phone and talked about memristors in 2005.


      def create_contract(self, code, endowment=0, sender=''):

           if not sender:

               sender = '82a978b3f5962a5b0957d9ee9eef472ee55b42f1' # PyEthereum uses ECDSA to derive this string from `sender = 0`.


           util.credit(db, sender, config.XCP, max(endowment*2, 100000000), action='unit test', event='facefeed')


           success, data = tester.state.do_send(self, sender, '', endowment, data=code)

           contract_id = data

           return contract_id


# Test serpent compilation of variables using _with_, doing a simple

# arithmetic calculation 20 * 30 + 10 = 610

sixten_code =\

   '''

(with 'x 10

   (with 'y 20

       (with 'z 30

           (seq

               (set 'a (add (mul (get 'y) (get 'z)) (get 'x)))

               (return (ref 'a) 32)

           )

       )

   )

)

'''





def test_sixten():

   s = tester.state()

   c = s.contract('')

   s.block.set_code(c, tester.serpent.compile_lll(sixten_code))

   o1 = s.send(tester.k0, c, 0, [])

   assert o1 == [610]



# Test Serpent's import mechanism



mul2_code = \

   '''

return(msg.data[0]*2)

'''



filename = "mul2_qwertyuioplkjhgfdsa.se"



returnten_code = \

   '''

x = create("%s")

return(call(x, 5))

''' % filename





def test_returnten():

   s = tester.state()

   open(filename, 'w').write(mul2_code)

   c = s.contract(returnten_code)

   o1 = s.send(tester.k0, c, 0, [])

   os.remove(filename)

   assert o1 == [10]




counterparty-lib provides a JSON RPC 2.0-based API based off of that of Bitcoin Core.


This type of memory is the most expensive - occupying a new cell in storage costs 20,000 gas- 26 cents. changing an occupied one costs 5,000, and reading costs 200. Why is it so expensive? The reason is simple - the data saved in the storage of the contract will be recorded in the blockchain and will remain there forever.

New bitcoin backend

Bitcore Node - https://github.com/bitpay/bitcore/tree/master/packages/bitcore-node

A standardized API to interact with multiple blockchain networks

Currently supporting: Bitcoin, Bitcoin Cash, Litecoin, Dogecoin, Ripple, Ethereum and Polygon

https://habr.com/ru/companies/domrf/articles/588737/


bitcore  v10.0.28 with packages/crypto-wallet-core/package.json

"ethers": "^5.7.0"  (Ethereum at list 5.7.0)

REST API Counterparty

Framework ethers instructions for use



const { ethers } = require('ethers')

const ContractArtifact = require('./SimpleMarketplace.json')

const CONTRACT_ADDRESS = ContractArtifact.networks['3'].address