/initial-pilot

Java client-server REST API to mimic HyFlexChain transactions

Primary LanguageJava

Locally running of besu (from root of project)

cd src/besu_local_test
./init_blockchain.sh

or simply run:

besu --network=dev --miner-enabled --miner-coinbase=0xfe3b557e8fb62b89f4916b721be55ceb828dbd73 --rpc-http-cors-origins="all" --host-allowlist="*" --rpc-ws-enabled --rpc-http-enabled --data-path=/tmp/tmpDatdir

To run the server

Run the class TransactionsApiApplication.java

To make a request to the server

Run this command on the terminal:

curl -X POST http://localhost:8080/api \
-H "Content-Type: application/json" \
-d '{"type":"Deposit", "amount":"1500"}'

or this one:

curl -X POST http://localhost:8080/api/deploy

or this one:

curl -X POST http://localhost:8080/api/contract-execution \
-H "Content-Type: application/json" \
-d '{"type":"Deposit", "amount":"1500", "sender": "0x549282910E81313D0a0975EEdDe05B23d5f6Ae08", "receiver": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", bytecode":"608060405234801561001057600080fd5b5060405161046d38038061046d8339818101604052602081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b50604052505081516100f6915060009060208401906100fd565b5050610190565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061013e57805160ff191683800117855561016b565b8280016001018555821561016b579182015b8281111561016b578251825591602001919060010190610150565b5061017792915061017b565b5090565b5b80821115610177576000815560010161017c565b6102ce8061019f6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80633d7403a31461003b578063e21f37ce146100e3575b600080fd5b6100e16004803603602081101561005157600080fd5b81019060208101813564010000000081111561006c57600080fd5b82018360208201111561007e57600080fd5b803590602001918460018302840111640100000000831117156100a057600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610160945050505050565b005b6100eb610177565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561012557818101518382015260200161010d565b50505050905090810190601f1680156101525780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b8051610173906000906020840190610205565b5050565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156101fd5780601f106101d2576101008083540402835291602001916101fd565b820191906000526020600020905b8154815290600101906020018083116101e057829003601f168201915b505050505081565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061024657805160ff1916838001178555610273565b82800160010185558215610273579182015b82811115610273578251825591602001919060010190610258565b5061027f929150610283565b5090565b5b8082111561027f576000815560010161028456fea2646970667358221220147e3493e823259bad903fca17af564b0149f4f3b5ee0efbce208a7d183c59c064736f6c63430007030033", "smartContractParams":"Hello World!"}'

or this one:

curl -X POST http://localhost:8080/api/private-transaction \
-H "Content-Type: application/json" \
-d '{"type":"Deposit", "amount":"1500", "sender": "0x549282910E81313D0a0975EEdDe05B23d5f6Ae08", "receiver": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "isPrivate":true}'

zokrates compilation:

curl -X POST http://localhost:8080/zokrates/compile

zokrates setup:

curl -X POST http://localhost:8080/zokrates/setup

zokrates compute-witness:

curl -X POST -H "Content-Type: application/json" -d '["0", "0", "1418887825", "19279996909834594640490546019708612104", "298368320004409627714642055275224819856", "25301665991035423237309602852572310550"]' http://localhost:8080/zokrates/compute-witness

zokrates generate-proof:

curl -X POST http://localhost:8080/zokrates/generate-proof

zokrates verify:

curl -X POST http://localhost:8080/zokrates/verify-proof

zokrates verify:

curl -X POST http://localhost:8080/zokrates/generate-and-verify-proof