Posted on

Getting Started with WAX Blockchain Development – Part 1

Part 1: Set Up for Development

In this lesson we will look at setting up a development environment for the WAX blockchain. Examples used will be primarily for those using Windows 10, but steps are adaptable to any platforms that Docker supports.

Step 1

First you will need to download and install Docker https://www.docker.com/

Docker is a container platform that creates virtual workstations and servers. More info here: https://www.docker.com/why-docker

You can then run the following from a command prompt to get the wax development container

c:\>docker pull waxteam/dev

Step 2

Create a folder to store your project files in. In this example we are using C:\projects\wax.

Open a cmd prompt and change directory to that folder path.

Step 3

Run the following command at the cmd prompt to start up the WAX container in interactive mode. The waxteam/dev is a local development environment including a local blockchain,

c:\>docker run -it --name waxdev -v c:\projects\wax:/wax waxteam/dev bash

The container waxteam/cdt is for creating and compiling smart contracts.

c:\>docker run -it --name waxcdt -v c:\projects\wax:/wax waxteam/cdt bash

Step 4

In WAX container in interactive mode you can run bash command like ls

root@de932f6fabf7:/# ls

and change directory to /wax

root@de932f6fabf7:/wax# cd /wax

Step 5

You can now test connectivity with the cleos wallet commands and get back JSON responses

cleos -u https://wax.greymass.com get info

or

cleos -u https://testnet.waxsweden.org get info

or

cleos -u https://chain.wax.io get info

Note: At the time of writing this article, chain.wax.io was responding with a parse error.

Continue to Part 2 (Coming Soon!)

Posted on

Remotely Enabling Remote Desktop

Windows Remote Management (WinRM) is enabled By default on a Windows Server, however Remote Desktop (RDP) is Disabled. 

Enabling RDP remotely by command line:

To enable RDP with the Command Prompt, use the following steps.

  1. Launch the Command Prompt as Administrator.
  2. Type the following command:
1Reg add “\\computername\HKLM\SYSTEM\CurentControlSet\Control\Terminal Server”  /v fDenyTSConnections /t REG_DWORD /d 0 /f

Where ‘Computername’ is the name of the computer you wish to enable RDP on.

Posted on

Developing Etherium Dapp on your Windows PC using Truffle – Step 4

This is a barebones walkthrough for developing a blockchain decentralized app (Dapp) for Etherium (ERC-20) based tokens. Goal is to go through all the steps needed to set up initial environment and build a first contract that compiles, deploys, test, and can interact with via web3.js Javascript in a web browser.

Step 4: Truffle Develop Console

In this step we will look at the Truffle console before starting testing. Be sure to complete Steps 1 to Step 3 before attempting this step.

1. At the command line in the project folder type:

truffle develop

This will start a development blockchain server and generate 10 test wallets. (NOTE: this is not real Etherium and will not work on MAINNET)

truffle develop

2. You are now in the Truffle development console. You can use the generated public and private wallet keys to test your DApp transactions.

3. You can also compile your project in the console with the command “compile”

truffle(develop)> compile
compile …

4. You can deploy your project in the console with the command “deploy”

truffle(develop)> deploy
deploy …

In the next step we will create a test package and run the test from the console.

Continue to Step 5 – Coming Soon!

Posted on

Windows Server Failover Clustering (WSFC) error code 5057

Error Message:

The Windows Server Failover Clustering (WSFC) resource control API returned error code 5057. The WSFC service may not be running or may not be accessible in its current state, or the specified arguments are invalid. For information about this error code, see “System Error Codes” in the Windows Development documentation.

At command prompt enter:

NET HELPMSG for 5057

You will then see that 5057 means “The cluster IP address is already in use.”

You can then ping – a the IP addresses and see which ones are in use.

Posted on

Developing Etherium Dapp on your Windows PC using Truffle – Step 3

This is a barebones walkthrough for developing a blockchain decentralized app (Dapp) for Etherium (ERC-20) based tokens. Goal is to go through all the steps needed to set up initial environment and build a first contract that compiles, deploys, test, and can interact with via web3.js Javascript in a web browser.

Step 3: Creating Variables and Functions

In this step we will add comments, state variables and functions to our contract. Be sure to complete Step 1 and Step 2 before attempting this step.

1. Comments can be designated in two ways. Use the // for single line and /* */ for multiline comments

// this is a single line comment
/*
   use this for
   multiline comments
*/

2. State variables are variables whose values are permanently stored in the blockchain. You can declare a state variable in the body of the contract. Visibility can be public, internal or private for state variables. A public state variable gets an automatically generated “getter” function.

Each statement ends with a semi-colon “;”

Also we will be using the datatype “uint” (not to be confused with ‘unit’) which stands for unsigned integer.

Add the following to the body of your contract.

//contract state variable
uint myVariable = 0;
State variable declaration

3. Functions are the bits of code that do something.

If the function reads but does not make any changes to the state of the contract it can be declared as a “view” function. If the function only acts on the input and does not read the state of the contract it can be declared as a “pure” function. These designations are important as they can help reduce the cost of Etherium to process the contract.

Visibility can be external, public, internal or private for functions.

Also, a common convention is to add an underscore to function parameters to avoid confusion between state variables at the contract scope and parameters in the function scope.

Add the following two functions to the body of your contract below the constructor.

function setMyVariable(uint _x) public {
   myVariable = _x;
}
function getMyVariable () public view returns (uint) {
   return myVariable;
}

10. Now save the file (in most editors is shortcut keys “Ctrl + s”). Now return to the Command Prompt window and compile your contract.

truffle compile

You should get results like the following. If you get any errors be sure the file is located in the right folder, the code matches, and the file has been saved.

Compile, Compile …

Continue to Step 4 – Truffle Develop Console

Posted on

Developing Etherium Dapp on your Windows PC using Truffle – Step 2

This is a barebones walkthrough for developing a blockchain decentralized app (Dapp) for Etherium (ERC-20) based tokens. Goal is to go through all the steps needed to set up initial environment and build a first contract that compiles, deploys, test, and can interact with via web3.js Javascript in a web browser.

Step 2: Creating a Contract

In this step we will set up the project, then create and compile an empty contract. Be sure to complete Step 1 before attempting this step.

1. Open a Command Prompt terminal. Can search for “cmd” in the start menu.

Open a cmd prompt window

2. Create a folder to house your project. For this example create a projects folder and myfirstdapp subfolder.

c:
cd c:\
mkdir projects
cd projects
mkdir myfirstdapp
cd myfirstdapp
Create folder for project

3. Create the folder structure for the Truffle project with the command:

truffle init
Initialize Truffle project

4. The project files can be created and edited with any text editor. It is helpful to use a tool that helps navigate the project. In this example we are using Atom. If you have Atom installed, you can just type “atom .” at the command prompt. Otherwise open your editor and navigate to the project folder.

atom .
Project folder open in Atom

5. We will be working mostly with the “contracts” and “test” folders for now.

contracts/: Directory for Solidity contracts
migrations/: Directory for scriptable deployment files
test/: Directory for test files for testing your application and contracts
truffle-config.js: Truffle configuration file

6. Navigate to the contracts folder and create a file named “MyContract.sol”

Your first contract

7. The very first line of every contract file will be the pragma indicating what version of solidity the contract was coded for. If you are following this tutorial using a newer version, then may need to update this value. More info on the structure of contracts is available here.

pragma solidity ^0.5.0;
First line is version pragma

8. Next will be the declaration of the contract. Note that the name of the contract and the file should match.

contract MyContract {
}
Contract declaration

9. Next will be the construction declaration for the contract which goes inside the contract declaration. Note that the constructor is declared as public.

   constructor() public{
   }
An empty contract

10. Now save the file (in most editors is shortcut keys “Ctrl + s”). You now have the minimum code for a contract. To compile the contract return to the Command Prompt window and type:

truffle compile

You should get results like the following. If you get any errors be sure the file is located in the right folder, the code matches, and the file has been saved.

Your first compile… of many…

Continue to Step 3 – Variables and Functions

Posted on

Developing Etherium Dapp on your Windows PC using Truffle – Step 1

This is a barebones walkthrough for developing a blockchain decentralized app (Dapp) for Etherium (ERC-20) based tokens. Goal is to go through all the steps needed to set up initial environment and build a first contract that compiles, deploys, test, and can interact with via web3.js Javascript in a web browser.

Step 1: Pre-Requisites

In this step we download and install the needed tools to set up our development environment.

Git is needed to retrieve software packages. Download and install Git for Windows: https://git-scm.com/download/win

Node.js is a server that allows execution of Javascript outside of a browser. Also includes NPM for downloading modules and packages. Download and install Node.js: https://nodejs.org/

Ganache gives you your own local blockchain node to develop with. Download and install Ganache: https://www.trufflesuite.com/ganache

MetaMask is crypto wallet & gateway to blockchain apps that turns your browser into a blockchain browser. You will also need to use a compatible browser such as Brave, Chrome, Firefox, or Edge. Install MetaMask: https://metamask.io/download.html

Install Truffle. After you have installed Nodejs, Truffle can be installed using NPM. Open up cmd shell and enter:

npm install -g truffle

It is also helpful to use a text editor that recognizes the Etherium programming language Solidity, for example:

For this walkthrough we will be using Atom.

Continue to Step 2 – Creating a Contract

Posted on

Max dates in database

Had a situation where needed to get an idea of when a database was last used. Created a quick query to generate select statements for all the date columns in all the user tables in the database.

    SELECT C.[name] "table_name"
         , A.[name] "column_name"
         , B.[name] "column_type"
         , 'union select ''' + C.name + '.' + A.name + ''' "column_name", max([' + A.name + ']) "maxdate" from [' + C.name + ']' "cmd"
      FROM sys.columns A
INNER JOIN sys.types B
        ON A.user_type_id = B.user_type_id
INNER JOIN sys.tables C
        ON A.object_id = C.object_id
     WHERE B.name like '%date%'
  ORDER BY C.name
         , A.name
Posted on

Error 35220 Creating Availability Group

In the process of setting up a new SQL Server 2019 instance and Availability Group, I ran into this error when executing the CREATE AVAILABILITY GROUP command

Error 35220: Could not process the operation. Always On Availability Groups replica manager is waiting for the host computer to start a Windows Server Failover Clustering (WSFC) cluster and join it. Either the local computer is not a cluster node, or the local cluster node is not online. If the computer is a cluster node, wait for it to join the cluster. If the computer is not a cluster node, add the computer to a WSFC cluster. Then, retry the operation.

As it turns out, I had checked the box to “Enable Always On Availability Groups” (AOAG) for the SQL instance after having installed the Windows Server Failover Cluster (WSFC), but before setting up the cluster. I had to disable AOAG, restart the SQL instance, enable AOAG and restart the SQL instance again. Then everything worked splendidly.

Posted on Leave a comment

Optimizing Stored Procedure Calls

  • Execute Stored Procedure with Fully Qualified Name (include schema, for example “EXEC dbo.mystoredproc”)
  • Execute Stored Procedure with same capitalization (upper/lower case) as it was created
  • Do not name stored procedures with “sp_” prefix unless you are specifically intending to create a global stored procedure (preferably in master database)
  • Make sure that the Stored Procedure execution query is sent to SQL as an RPC instead of a Language Event. For example, for the .Net command object be sure to explicitly set CommandType to StoredProcedure

Additional information:

https://support.microsoft.com/en-us/help/263889/how-to-troubleshoot-blocking-caused-by-compile-locks

http://c-bit.org/kb/263889/EN-US/