DEV Community

Dhfernando for AWS Community Builders

Posted on

Amazon Managed Blockchain

Hi Today Im going to explain about what is this AWS Managed Blockchain and quick getting started guid, So let's go.

First of all what is this Blockchain?
Blockchain technology has taken the world by storm in recent years, with its ability to offer decentralized and secure transaction management. It's widely used for cryptocurrency transactions, but it's also being applied in various industries, including finance, healthcare, and supply chain management. AWS Managed Blockchain is Amazon's service that provides a managed blockchain service for businesses to create and manage scalable blockchain networks.

To understand AWS Managed Blockchain, let's first understand what blockchain technology is. At its core, a blockchain is a decentralized and distributed ledger that stores transactional data. It's called a blockchain because it's a chain of blocks, where each block contains a list of transactions. Each block is connected to the previous block, creating a chain of blocks. These blocks are encrypted, immutable, and tamper-proof, making it extremely secure. The key to the security of the blockchain is its decentralized nature, which ensures that no single entity can control the blockchain.

AWS Managed Blockchain is a fully managed service that enables businesses to create and manage scalable blockchain networks. With AWS Managed Blockchain, businesses can quickly and easily set up their own blockchain networks without having to worry about the underlying infrastructure. The service provides a range of blockchain frameworks to choose from, including Ethereum and Hyperledger Fabric.

AWS Managed Blockchain is designed for businesses that want to use blockchain technology but do not want to manage the underlying infrastructure. By using AWS Managed Blockchain, businesses can focus on building their applications and services, rather than worrying about the infrastructure. AWS Managed Blockchain also provides a range of security features, such as encryption, identity management, and access controls, to ensure the security of the blockchain network.

One of the main advantages of AWS Managed Blockchain is its scalability. With AWS Managed Blockchain, businesses can easily scale their blockchain network as their business grows. AWS Managed Blockchain provides automatic scaling and redundancy, ensuring that the blockchain network can handle high volumes of transactions. The service also provides a range of monitoring and logging features, enabling businesses to monitor the health and performance of their blockchain network.

To get started with AWS Managed Blockchain

, businesses can use the AWS Management Console or the AWS Command Line Interface (CLI). With the Management Console, businesses can quickly set up their blockchain network and manage it from a single dashboard. The Management Console provides a range of tools, such as network creation wizards, that make it easy to create and manage a blockchain network.

Using the AWS CLI, businesses can automate the creation and management of their blockchain network. The AWS CLI provides a range of commands, such as create-network, create-member, and create-proposal, that enable businesses to create and manage their blockchain network. The AWS CLI also provides a range of monitoring and logging features, enabling businesses to monitor the health and performance of their blockchain network.

AWS Managed Blockchain can be used in a range of industries, including finance, healthcare, and supply chain management. In finance, AWS Managed Blockchain can be used for payment processing and clearing and settlement. In healthcare, AWS Managed Blockchain can be used for secure and decentralized medical record management. In supply chain management, AWS Managed Blockchain can be used for product tracking and tracing.

To create a new blockchain network using Hyperledger Fabric, we'll use the AWS CLI. First, we'll create a new network using the create-network command. We'll specify the name of the network, the framework (in this case, Hyperledger Fabric), and the voting policy for accepting proposals.

aws managedblockchain create-network --region <region> \
--client-request-token <token> \
--name <network-name> \
--framework Hyperledger_Fabric \
--voting-policy MajorityVoting
Enter fullscreen mode Exit fullscreen mode

Here's what each of the parameters means:

  • region: The AWS region where the network should be created.
  • client-request-token: A unique identifier for the network. You can use any string, but it must be unique within your account.
  • name: The name of the network.
  • framework: The name of the blockchain framework to use. In this case, we're using Hyperledger Fabric.
  • voting-policy: The voting policy for accepting proposals. We're using the default value of MajorityVoting.

Once the network has been created, we can create a new member and add it to the network using the create-member and create-node commands.

aws managedblockchain create-member --region <region> \
--client-request-token <token> \
--network-id <network-id> \
--member-configuration Name=<member-name>,Description=<description>,FrameworkConfiguration={Fabric={AdminUsername=<username>,AdminPassword=<password>}}

aws managedblockchain create-node --region <region> \
--client-request-token <token> \
--network-id <network-id> \
--member-id <member-id> \
--node-configuration InstanceType=<instance-type>,AvailabilityZone=<availability-zone>,LogPublishingConfiguration={Fabric={ChaincodeLogs={Cloudwatch={Enabled=true}},PeerLogs={Cloudwatch={Enabled=true}}}}
Enter fullscreen mode Exit fullscreen mode

Lets explore who can we integrate blockchain with other services on AWS

Let's say we want to create a blockchain network using the Hyperledger Fabric framework. Here's how we can do it using the AWS CLI:

  1. Set up AWS CLI
    Before we start, make sure you have the AWS CLI installed and configured with your AWS account credentials.

  2. Create a Network
    First, we need to create a network. We'll use the create-network command to create a new network.

aws managedblockchain create-network --name my-network --description "My Hyperledger Fabric network" --framework Hyperledger_Fabric --framework-version 1.4.0 --voting-policy "ApprovalThresholdPolicy {ThresholdPercentage=100, ProposalDurationInHours=24, ThresholdComparator=GREATER_THAN_OR_EQUAL_TO}" --member-configuration '{"Name":"MyOrg1","Description":"My first organization","FrameworkConfiguration":{"Fabric":{"AdminUsername":"admin","AdminPassword":"passw0rd"},"NetworkConfiguration":{"Edition":"STARTER","VpcEndpointServiceName":"com.amazonaws.us-west-2.managedblockchain","SubnetIds":["subnet-0123456789abcdef0","subnet-0123456789abcdef1"],"AvailabilityZone":"us-west-2a"}}}'
Enter fullscreen mode Exit fullscreen mode

This command creates a new network named "my-network" with a description "My Hyperledger Fabric network" using the Hyperledger Fabric framework version 1.4.0. It also sets a voting policy for the network and configures the first member of the network with the name "MyOrg1" and a description "My first organization".

The member configuration specifies the network edition as "STARTER" and sets the VPC endpoint service name for the network. It also specifies the subnets to use for the network and the availability zone.

  1. Create a Node Next, we need to create a node for the network. We'll use the create-node command to create a new node
aws managedblockchain create-node --network-id n-0123456789abcdef0 --member-id m-0123456789abcdef0 --node-configuration '{"InstanceType":"bc.t3.small","AvailabilityZone":"us-west-2a","LogPublishingConfiguration":{"Fabric":{"ChaincodeLogs":"ENABLED","PeerLogs":"ENABLED","CaLogs":"ENABLED"}}}'
Enter fullscreen mode Exit fullscreen mode

This command creates a new node for the network with the specified network ID and member ID. It also specifies the node instance type and availability zone. Additionally, it enables logging for the

chaincode, peer, and Certificate Authority (CA) for the node.

  1. Create a Proposal Now that we have a node for the network, we can create a proposal to add a member to the network. We'll use the create-proposal command to create the proposal.
aws managedblockchain create-proposal --network-id n-0123456789abcdef0 --member-id m-0123456789abcdef0 --actions Invitations=[{\"Principal\":\"arn:aws:iam::123456789012:root\",\"Action\":\"INVITE\"}] --description "Invite new member to the network"
Enter fullscreen mode Exit fullscreen mode

This command creates a proposal to invite a new member to the network with the specified network ID and member ID. It specifies the action to invite the principal with the specified ARN, and sets a description for the proposal.

  1. Vote on the Proposal Once the proposal is created, other members of the network can vote on it. We'll use the vote-on-proposal command to vote on the proposal.
aws managedblockchain vote-on-proposal --network-id n-0123456789abcdef0 --member-id m-0123456789abcdef1 --proposal-id p-0123456789abcdef0 --vote YES
Enter fullscreen mode Exit fullscreen mode

This command votes "YES" on the proposal with the specified network ID, member ID, and proposal ID.

  1. Monitor the Network Once the proposal is approved, the new member will be added to the network. You can use the list-members command to list the members of the network.
aws managedblockchain list-members --network-id n-0123456789abcdef0
Enter fullscreen mode Exit fullscreen mode

This command lists the members of the network with the specified network ID.

Use the Network
Now that we have a fully functioning blockchain network, we can use it for various use cases. For example, we can deploy and execute smart contracts on the network using Hyperledger Fabric.

# Deploy Chaincode
aws managedblockchain create-proposal --network-id n-0123456789abcdef0 --member-id m-0123456789abcdef0 --actions Name=chaincode,Action=DEPLOY,Input='{\"Type\":\"GOLANG\",\"ChaincodeName\":\"mychaincode\",\"ChaincodeVersion\":\"1.0\",\"ChaincodePackage\":\"<base64-encoded-chaincode-package>\"}' --description "Deploy mychaincode to the network"

# Execute Chaincode
aws managedblockchain create-proposal --network-id n-0123456789abcdef0 --member-id m-0123456789abcdef0 --actions Name=chaincode,Action=INVOKE,Input='{\"ChaincodeName\":\"mychaincode\",\"Fcn\":\"myfunction\",\"Args\":[\"arg1\",\"arg2\"]}' --description "Invoke myfunction on mychaincode"
Enter fullscreen mode Exit fullscreen mode

These commands demonstrate how to deploy and execute chaincode on the network.

In conclusion, AWS Managed Blockchain is a powerful tool for creating and managing blockchain networks. It provides a seamless experience for setting up and managing the infrastructure required for a blockchain network, allowing developers to focus on building their applications. With support for popular blockchain frameworks like Hyperledger Fabric, AWS Managed Blockchain is an excellent choice for any blockchain use case.

Top comments (0)