Skip to main content

 none
Error in createcontract azure blockchain rest api RRS feed

  • Question

  • I have created the helloblockchain using azure blockchain workbench.  Then created a helloblockchain web app to test the blockchain rest APIs and have encountered an error.  I am getting the following error when creating new contracts.  The contracts are created but the following application insight shows there is an error in the build.  I am sending the correct parameters.  Any idea why this error is happening?  I am not getting an error when I create a contact using the workbench UI.

    LogLevel created Message ServiceName SourceContext Method Exception
    Information 2019-07-29 [06:06:17 PM] Getting transaction receipt for "0x6abd36ad1d23d1bab54b709eb4064b486025012623a8b0338926db5bc9e657d3" eth-watcher NethereumService null
    Information 2019-07-29 [06:06:13 PM] Burn transaction nonce succeeds. eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:13 PM] Updating contract action 51 with provisiong stauts FailedToSubmitAndNonceConsumed eth-tx-submitter Host CreateContractAction  
    Information 2019-07-29 [06:06:13 PM] Transaction 0x6abd36ad1d23d1bab54b709eb4064b486025012623a8b0338926db5bc9e657d3 is submitted to transaction pool successfully. eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:13 PM] New contract's address is calculated, from:0xd62a6fd5ccfaf9cc565f8a414780501329476134; nonce:41; to:0x22e71d88563f643f97d369d0380c3d82f97c9d96. eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] to = , amountHexBigInteger=0, nonceHexBigInteger=41, gasPriceHexBigInteger=0, gasLimitHexBigInteger=30000 eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] Calling Nethereum.Signer.Transaction eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] Construct and send transaction to blockchain for nonce burning. eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] Action is newly created, InitializeTransactionInformation failed, go to burn transaction nonce. eth-tx-submitter Host CreateContractAction  
    Information 2019-07-29 [06:06:12 PM] Updating contract action 51 with provisiong stauts FailedToSubmit eth-tx-submitter Host CreateContractAction  
    Error 2019-07-29 [06:06:12 PM] Expecting 1 input parameters but found 0. eth-tx-submitter Host CreateContractAction Microsoft.Azure.Blockchain.Eth.TxSubmitter.EthTxSubmitterException
    Error 2019-07-29 [06:06:12 PM] Expecting 1 input parameters but found 0. eth-tx-submitter Host CreateContractAction  
    Information 2019-07-29 [06:06:12 PM] Construct transaction for contract deploy. eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] TransactionInput for normal transaction and Send to Web3 machine for Gas estimate eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] Getting transaction info for contractActionId 51. eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] Receive compiled code for application {applicationId}, contract {contractName}, adding to local memory cache. eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] Get compiled contract successfully for applicaiton {applicationId}, contract {contractName} eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] Querying compiled code blob url for application 1, contract HelloBlockchain. eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] Get work item detail: applicationId: 1; contractName: HelloBlockchain; from: 0xd62a6fd5ccfaf9cc565f8a414780501329476134; to: ; nonce: 41; sequenceNumber: 41; methodName: eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] Getting pending contract action item for contract action 51. eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] Request finished in 55.2221ms 200 application/json; charset=utf-8 appbuilder.api Microsoft.AspNetCore.Hosting.Internal.WebHost /api/v1/contracts
    Information 2019-07-29 [06:06:12 PM] ProcessContractActionRequest: baseNonce: 0; contractActionId: 51 eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] Transaction machine is just created for contractAction: 51. eth-tx-submitter Host CreateContractAction
    Information 2019-07-29 [06:06:12 PM] Executing sproc "[dbo].[CreateContract]" appbuilder.api data-access /api/v1/contracts
    Information 2019-07-29 [06:06:12 PM] Executing [dbo].[CreateContract] appbuilder.api data-access /api/v1/contracts
    Information 2019-07-29 [06:06:12 PM] Authorization was successful for user: "rrutiaga@ditxmoutlook.onmicrosoft.com". appbuilder.api Microsoft.AspNetCore.Authorization.DefaultAuthorizationService /api/v1/contracts
    Information 2019-07-29 [06:06:12 PM] Executing sproc "[dbo].[GetUserChainMappings]" appbuilder.api data-access /api/v1/contracts
    Information 2019-07-29 [06:06:12 PM] Execute [dbo].[GetUserChainMappings] with id = 1 appbuilder.api data-access /api/v1/contracts
    Information 2019-07-29 [06:06:12 PM] Executing sproc "[dbo].[GetUserByExternalId]" appbuilder.api data-access /api/v1/contracts
    Information 2019-07-29 [06:06:12 PM] Execute [dbo].[GetUserByExternalId] with externalId = "c32a26d0-9f82-44ff-9be3-130379dd10ce" appbuilder.api data-access /api/v1/contracts


    • Edited by rrutiaga Tuesday, July 30, 2019 6:37 PM
    Tuesday, July 30, 2019 1:32 PM

All replies

  • Greetings,

    Thank you for your message.  A likely cause for not being able to create a contract via the API is because of not setting the user's role correctly.  Let me explain.

    An application in Azure Blockchain Workbench consists of roles.  One can think of these roles as a means for doing role-based control and prevent users in unauthorized roles from taking actions.  A user has to be explicitly assigned a role.

    There are two roles in the HelloBlockchain application - a requestor and a responder.  Only a user in a requestor role can create a contract.  It could be the case that you have not assigned the requestor role to yourself.  It is possible to assign a role via the set of APIs.  Here is the full API list.  

    Please try the following steps, in order, to assign the Requestor role for yourself and check the creation of a contract.  The links take you to the corresponding API calls.

    1. Get the Role Assignment ids for the roles using Role Assignments Get.  Note down the role id for Requestor.
    2. Get the user id using Users Get. Note down the user id.
    3. Use Role Assignments Post to create a role assignment.  Provide the role id for Requestor and user id.  Please note that this API can only be called by a Workbench Administrator.
    4.  Create an smart contract instance using Contract Post. Please note that you will need the workflowId, contractCodeId, and connectionId using gets for Workflow, ContractCode, and Connection. You will also need ApplicationId for making these calls and can be obtained from Applications.

    Please let us know how this goes.

    Thanks.


    Microsoft Azure Blockchain Team


    Wednesday, July 31, 2019 9:15 PM
    Owner
  • Hi rrutiaga Were you able to resolve your issue? Was the proposed answer helpful?
    Friday, August 2, 2019 4:23 AM
    Moderator
  • Hi rrutiaga just touching base to see if you have any updates?
    Saturday, August 3, 2019 1:45 AM
    Moderator
  • Hi Alberto,

    I figured out what the error was.  I had a misspelled  constructor parameter on the blockchain create contract api call.  Once I corrected the name, the contract creation worked as expected.  Thank you!

    Thursday, August 8, 2019 3:58 AM
  • Greetings,

    Thank you for your message.  A likely cause for not being able to create a contract via the API is because of not setting the user's role correctly.  Let me explain.

    An application in Azure Blockchain Workbench consists of roles.  One can think of these roles as a means for doing role-based control and prevent users in unauthorized roles from taking actions.  A user has to be explicitly assigned a role.

    There are two roles in the HelloBlockchain application - a requestor and a responder.  Only a user in a requestor role can create a contract.  It could be the case that you have not assigned the requestor role to yourself.  It is possible to assign a role via the set of APIs.  

    Please try the following steps, in order, to assign the Requestor role for yourself and check the creation of a contract.  The links take you to the corresponding API calls.

    1. .

    Please let us know how this goes.

    Thanks.


    Microsoft Azure Blockchain Team


    Hi, when sending Get roleAssignment api request, how can I know what is the applicationRoleId for requestor?
    Thursday, August 15, 2019 7:59 PM