smartcontracts

Chaincode (smart contract) interactions within and across channels in Hyperledger Fabric

China☆狼群 提交于 2020-01-02 05:29:07
问题 Consider the Organization-Peer setup in a Hyperledger Fabric network as shown in the image. Org 1 has two peers, Org 2 has one peer - all of which exist inside the same channel - X. Org 3 has one peer which exist outside in a different channel. The peers have distinct chaincodes(c1, c2, c3 & c4) installed in each of them with the functions as explained. write() - put a key-value pair into the ledger update() - update a value for an existing key read() - query an existing key-value pair Now on

How to call the smart contract methods from android app using web3j

余生长醉 提交于 2019-12-24 18:18:26
问题 I want to call the smart contract methods from an Android app. I deployed the smart contract using truffle framework in my private network. I also created a wrapper class for the deployed smart contract using web3j commands. It creates a .java file in my Android project. I want to call smart contract methods from my Android app. This is my code: import android.net.Credentials; import android.renderscript.Type; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import

Solidity compiler - problem with HelloWorld smart contract

我们两清 提交于 2019-12-23 05:15:37
问题 Im trying to run my first HelloWorld smart contract on the Enthereum network. This is my HelloWorld.sol contract. pragma solidity ^0.5.0; contract HelloWorld { bytes32 message; constructor (bytes32 myMessage) public { message = myMessage; } function getMessage() public returns(bytes32) { return message; } } When I try to build this using solcjs HelloWorld.sol --bin , there is just one Warning and no errors. I have installed web3 and solc using npm. When I run this on a node var solc = require

How can I return an array of struct in solidity?

佐手、 提交于 2019-12-18 06:48:11
问题 I am designing a solution for an ethereum smart contract that does bidding . The use-case includes reserving a name eg. "myName" and assigning to an address. And then, people can bid for that name (in this case myName). There can be multiple such biddings happening for multiple names . struct Bid { address bidOwner; uint bidAmount; bytes32 nameEntity; } mapping(bytes32 => Bid[]) highestBidder; So, as you can see above, Bid struct holds data for one bidder, similarly, the key (eg. myName) in

Interacting with the smart contract from Java application (We3j)

╄→尐↘猪︶ㄣ 提交于 2019-12-12 19:17:42
问题 I have many questions about the workflow ( sequence ) of interacting with the smart contract from Java application, so I will first explain what I have done and then put my questions, and if something wrong in my understanding please let me know. 1- I have written smart contract 2- Use truffle to get the smart contract java wrapper.(contract.java) 3- Use testrpc to test the contract I have 2 class uses testrpc accounts (credentials) to interact with the smart contract and call its functions

Web3j v3.3.1 : Error while generating compiled solidity smart contracts which returns array of struct

北城以北 提交于 2019-12-11 21:32:52
问题 I am returning an array of struct from solidity function as below. pragma solidity ^0.4.21; pragma experimental ABIEncoderV2; function getPurchaseOrderForVendor(string vendorNameInput) constant returns (PurchaseOrderStruct[]) It is compiled to abi and bin files. The issue is with creating wrapper files for the contract using web3j(v3.3.1). Im getting the below errors. Generating com.contract.InvoiceSettlement_sol_InvoiceSettlement ... Exception in thread "main" java.lang

How to compile solidity using solc 0.5

时光总嘲笑我的痴心妄想 提交于 2019-12-11 05:58:14
问题 compile.js : const path = require('path'); const solc = require('solc'); const fs = require('fs-extra'); const buildPath = path.resolve(__dirname, 'build'); fs.removeSync(buildPath); const campaignPath = path.resolve(__dirname, 'contracts', 'Campaign.sol'); const source = fs.readFileSync(campaignPath, 'utf8'); var input = { language: 'Solidity', sources: { 'Campaign.sol': { content: source } }, settings: { outputSelection: { '*': { '*': [ '*' ] } } } } const output = solc.compile(input, 1)

Solidity: Can a Parent contract see data updates from a Child contract?

妖精的绣舞 提交于 2019-12-11 01:44:45
问题 I have a premature implementation of an Ethereum game. I have divided my code in two contracts, separating "game" functions from functions called by the Admin. Admin.sol inherits from Game.sol as seen below. A struct object is created in Admin, but Game cannot see it. (Getter function returns nothing) import "./Game.sol"; contract Admin is Game The same code, if not divided in two contracts, works perfectly. Header of function in Admin.sol that creates the object: function createJob(string

Render JavaScript number as solidity ERC20 decimals

梦想与她 提交于 2019-12-10 20:41:56
问题 When you create an ERC20 cryptocurrency in solidity you initialize it with a number of decimals. If you total supply is 10k and the number of decimals is 4, your token supply will display as 100000000 (10,000.0000). In Solidity, you simply do YourNumber*10**4 to initialize a number like 10,000.0000 where YourNumber = 10,000 I wanted to do a simple calculator in JavaScript where, based on the user input we give them their input in decimals of a token. Say the maximum number of decimals is 4

Solidity - Solidity code to Input JSON Description

谁都会走 提交于 2019-12-06 04:09:40
I want to compile my ehtereum HelloWorld.sol smart contract. In all the tutorials is that you do it like this: var solc = require('solc'); var compiledContract = solc.compile(fs.readFileSync('HelloWorld.sol').toString(); where HelloWorld.sol is: pragma solidity ^0.5.1; contract HelloWorld { bytes32 message; constructor(bytes32 myMessage) public { message = myMessage; } function getMessage() public view returns(bytes32){ return message; } } In other words I put my raw Solidity contract code into the solc.compile() method. But this process gives me this error in compiledContract: '{"errors":[{