createNode method

Future<CreateNodeOutput> createNode({
  1. required String networkId,
  2. required NodeConfiguration nodeConfiguration,
  3. String? clientRequestToken,
  4. String? memberId,
})

Creates a node on the specified blockchain network.

Applies to Hyperledger Fabric and Ethereum.

May throw InvalidRequestException. May throw AccessDeniedException. May throw ResourceNotFoundException. May throw ResourceAlreadyExistsException. May throw ResourceNotReadyException. May throw ThrottlingException. May throw ResourceLimitExceededException. May throw InternalServiceErrorException.

Parameter networkId : The unique identifier of the network for the node.

Ethereum public networks have the following NetworkIds:

  • n-ethereum-mainnet
  • n-ethereum-rinkeby
  • n-ethereum-ropsten

Parameter nodeConfiguration : The properties of a node configuration.

Parameter clientRequestToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the operation. An idempotent operation completes no more than one time. This identifier is required only if you make a service request directly using an HTTP client. It is generated automatically if you use an AWS SDK or the AWS CLI.

Parameter memberId : The unique identifier of the member that owns this node.

Applies only to Hyperledger Fabric.

Implementation

Future<CreateNodeOutput> createNode({
  required String networkId,
  required NodeConfiguration nodeConfiguration,
  String? clientRequestToken,
  String? memberId,
}) async {
  ArgumentError.checkNotNull(networkId, 'networkId');
  _s.validateStringLength(
    'networkId',
    networkId,
    1,
    32,
    isRequired: true,
  );
  ArgumentError.checkNotNull(nodeConfiguration, 'nodeConfiguration');
  _s.validateStringLength(
    'clientRequestToken',
    clientRequestToken,
    1,
    64,
  );
  _s.validateStringLength(
    'memberId',
    memberId,
    1,
    32,
  );
  final $payload = <String, dynamic>{
    'NodeConfiguration': nodeConfiguration,
    'ClientRequestToken': clientRequestToken ?? _s.generateIdempotencyToken(),
    if (memberId != null) 'MemberId': memberId,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/networks/${Uri.encodeComponent(networkId)}/nodes',
    exceptionFnMap: _exceptionFns,
  );
  return CreateNodeOutput.fromJson(response);
}