1656131940
valve is an conflux framework which helps with Initialize a dapp project. inspird by truffle && ganache!
The framework makes the development of smart contracts in the conflux network pretty easy. It provides commands for compilation, deployment of smart contracts, running a local node, local compiler and unit testing the contracts.
valve consists of 5 separated packages. There are two main packages.
npm i -g conflux-valve
Before you start you must locally run a our conflux chain node. If you want to build by yourself, just fellow this: https://https://github.com/Conflux-Chain/conflux-docker
docker pull liqiazero/conflux-chain:v0.2.4
docker run --name conflux-chain -p 12537:12537 -p 32323:32323 -p 32323:32323/udp -p 14629:14629 -p 12539:12539 -d liqiazero/conflux-chain:v0.2.4
if u want use docker-compose, just following:
To start the network:
docker-compose up -d
To destroy the network:
docker-compose down
To cleanup the associated docker volumes, -v
option could be used:
docker-compose down -v
valve init
Put your own contract under the current directory
valve account
Generate account and private key .
You can find the generated wallet.json file in the current directory. All address, privatekey, publishkey will be written to this file.
The following content :
{
"wallet": [
{
"time": "2019-12-13 11:49:43",
"mnemonic": "accuse erosion version giant surprise hour course devote frozen cabbage birth fog",
"accounts": [
{
"address": "0xa7b4e98db3d570bd6cf01141dfc69a58b0eba3d7",
"publicKey": "0x3f2b115a74c0cecf197b8608d71890f3801c3ddc54bb5e50c2c83be9169b5c0224a70f5381a8c3ae2ea8065c476498c774b39f4093ecd6b687912d5ebd83452e",
"privateKey": "0x4270f5706de09280ff78cc91d3e02ce7a209538ce4fcf9b21d55196d5c89ac01"
},
{
"address": "0xd886f98626094a77d831a91ed15e2b0e2d463416",
"publicKey": "0xa3029052cd227709e2cdaefec0088a0248f00934bfe70022ec24c8b7f6bdd8c9de85b16a21632b536ca22f917eb3798c5b20644720667cd9bffe3fd7c12a5ec1",
"privateKey": "0xe5a0ddb5bae3cd7649981a5735c4eef3680969aa9e1852e0946e5313117f29d4"
},
{
"address": "0x297d58cc2f7bb0fd14c65e1b040d7c7d30f4db69",
"publicKey": "0x44c861480c5a0d45a8c56bbe95dac6ab933956d60e997c8acb866654a9584a4c47b77bc0f85ff031dfdce3df32318ad509ff5a1fbe71982e9a3030a1cea3b8aa",
"privateKey": "0x09a2975c885f4c9861c7cb4f9912b12c476fef35b9415e551d162143adfcc799"
},
{
"address": "0xd5ac5b46d4a1e18e41082e6e87939d38258dcd10",
"publicKey": "0x235a3e11267bf73dd652af3eea95eb7a757a535945a296a9f0c5c362f851f2335cec8beddaf51fd10c2ce88c760b2be1d2fd78537914b3fa473b6cd105fd4803",
"privateKey": "0xaa7197c6cac1950dd1ccef2f6af2372e4e66ea14f7b47f53ba25d7daa2f8d211"
},
{
"address": "0x93dccd823eb68f7739ab67990afeaf1b25729773",
"publicKey": "0x4610b40ada45976ae58d191ca8a7e0b088aa5148437bb1cb89c20d1c53587159721fd5301192bf44c6101e23d2b816f0c5c6ec7318933bf79d693b435310c461",
"privateKey": "0xfe4db093fecafb026396731e0489ce7d2263fb0958d7487c124985eabe173b5d"
},
{
"address": "0x5d38e928f2ed257a444a03fbc0fbf8e3eeb09fde",
"publicKey": "0x8a677fae9f146340641cf6d69b2ad7f474f4451ed41a1062c339eba4bf488f6ddf16bf663777ad4aadff592e9c062a0a2221d4fbc75349c5ab21ca02ffd72700",
"privateKey": "0xea337ea5dfca6f1e113f5cb0837987c88c089daa522234bea55d1dc77fd54eff"
},
{
"address": "0x1ecc9404876f127e422e06ad1ff4cd9d2a282ee4",
"publicKey": "0x205e612bf30e206f1509f93571a675c2d10a2d1330de4c85996edeafcaccb3d77aabe20c36c564eb32f7f39d66e60c7006c213f87ce26d17407f206a0925bdee",
"privateKey": "0xfbede3f6f97b625a692b45ef5bdc3ac03cdfe88ca00eb340b69f06e7aaa54904"
},
{
"address": "0x71fd598723355d0d3a25aed255a6075e5fa5394c",
"publicKey": "0x8a7599e25d4f073a99cc5f65bfb118c767d33be465da85af4b1087a3680286b30c4aa806abf491bb4c60f9ec051258feb57995be66a4ed8c50c21bda671be90c",
"privateKey": "0x4117984ea58a4741f068ef6e78844a74d6ff2a890cf2c5413b069e9d9ee64831"
},
{
"address": "0x79305dc2b3509212bb043befebb12a46d3cb190b",
"publicKey": "0xe18a6387b06092bb7cdfb56f18759a5088b748b0c1c0fb2618cff0ea024c0d5d50256b81e2e9f687ce6758864daafebe406bdab5a8ad71decf3afe15d9b239b6",
"privateKey": "0x556bbe7db0055f894179efe6bbbfa9274dfb2bbde8ca063113318fea435247c0"
},
{
"address": "0x9535ad60bf720baac2e8ab3a9308c46879241968",
"publicKey": "0xccb514ddafd7e6238923d4ea2f09a27b4f852a855d307efec938fb3c68862deb0058ccca8a799df360ca13cc1979117e2cbbc0f7180c5f57af08828a89e16da5",
"privateKey": "0x998340f60cbcb8b26b5cd3b851fc0546c2adf7daad6ac30ab1fb227424ade67f"
}
]
}
]
}
example:
valve compile
if you have multiple contracts, libraries, etc., there is a reference relationship between them. When compiling, valve will automatically do the linking for you. But you need to deploy your contracts in the order suggested.
.........
.........
-------------------------------------------- │
output: { contracts: │
{ 'ConvertLib.sol': { ConvertLib: [Object] }, │
'MetaCoin.sol': { MetaCoin: [Object] }, │
'Migrations.sol': { Migrations: [Object] } }, │
sources: │
{ 'ConvertLib.sol': { id: 0 }, │
'MetaCoin.sol': { id: 1 }, │
'Migrations.sol': { id: 2 } } }
U need first deploy this contract: [ 'ConvertLib.sol', 'Migrations.sol' ]
then deploy this contract: [ 'MetaCoin.sol' ]
To compile your contract, will generate build directory down generated abi and the bytecode.
Give your address some CFX coin.
example:
valve sendbalance --a "0xe1680683be13895b59c94eaf61818975a0d105dd"
default:
wallet addressIndex[0] as the default deploy address
Select the address and privatekey you want to deploy in the wallet.json file.
Ensure that your account has plenty of cfx coin, if not you can use valve sendbalance send some to your account.
example:
valve deploy --a "0xe1680683be13895b59c94eaf61818975a0d105dd" --pk "0x91594bd85fec9695a26ed630f536195b5f8c448560f46d68512e2efcd837d0ac" --name ConvertLib
Will be sent to test network related contracts over the contract.
If you are successful, you will receive the following log:
example:
you can find the transaction details on : http://www.confluxscan.io/transactionsdetail/0x5a8234da84f0c066780921a04b2cbc94d6e48a343cd9ae5bda5479d78a883f76
..............
Your contract has been deployed at :0xae2b17be6f7d590510fa7db89f86c02f55e73d2a
Home> valve console
commands: { compile:
{ command: 'compile',
description: 'compile contracts',
builder: {},
help: { usage: 'valve compile', options: [] },
run: [AsyncFunction: run] },
deploy:
{ command: 'deploy',
description: 'deploy contracts',
builder: {},
help: { usage: 'valve deploy', options: [] },
run: [AsyncFunction: run] },
sendbalance:
{ command: 'sendbalance',
description: 'send balance(30 cfx coin) to a address',
builder: {},
help: { usage: 'valve sendbalance', options: [] },
run: [AsyncFunction: run] },
account:
{ command: 'account',
description: 'generate address && priv
ate key',
builder: {},
help: { usage: 'valve account', options: [] },
run: [AsyncFunction: run] } }
valve(localhost_docker)> compile
start compile all the contracts, pls wait....
--------------------------------------------
output: { contracts:
{ 'ConvertLib.sol': { ConvertLib: [Object] },
'MetaCoin.sol': { MetaCoin: [Object] },
'Migrations.sol': { Migrations: [Object] } },
sources:
{ 'ConvertLib.sol': { id: 0 },
'MetaCoin.sol': { id: 1 },
'Migrations.sol': { id: 2 } } }
..................................
valve(localhost_docker)> cfx.
cfx.__defineGetter__ cfx.__defineSetter__ cfx.__lookupGetter__ cfx.__lookupSetter__
cfx.__proto__ cfx.hasOwnProperty cfx.isPrototypeOf cfx.propertyIsEnumerable
cfx.toLocaleString cfx.toString cfx.valueOf
cfx.Account cfx.Contract cfx.call cfx.close
cfx.constructor cfx.estimateGas cfx.getBalance cfx.getBestBlockHash
cfx.getBlockByEpochNumber cfx.getBlockByHash cfx.getBlockByHashWithPivotAssumption cfx.getBlocksByEpochNumber
cfx.getCode cfx.getEpochNumber cfx.getGasPrice cfx.getRiskCoefficient
cfx.getTransactionByHash cfx.getTransactionCount cfx.getTransactionReceipt cfx.setProvider
cfx.defaultEpoch cfx.defaultGas cfx.defaultGasPrice cfx.getLogs
cfx.provider cfx.sendRawTransaction cfx.sendTransaction
valve(localhost_docker)> cfx.defaultEpoch
'latest_state'
valve(localhost_docker)> cfx.defaultGas
1000000
valve(localhost_docker)> cfx.defaultGasPrice
100
valve(localhost_docker)> (await cfx.getBalance("0xe1680683be13895b59c94eaf61818975a0d105dd")).toString()
'199937499999800000000'
valve(localhost_docker)> MetaCoin.
MetaCoin.__defineGetter__ MetaCoin.__defineSetter__ MetaCoin.__lookupGetter__ MetaCoin.__lookupSetter__ MetaCoin.__proto__
MetaCoin.hasOwnProperty MetaCoin.isPrototypeOf MetaCoin.propertyIsEnumerable MetaCoin.toLocaleString MetaCoin.valueOf
MetaCoin.apply MetaCoin.bind MetaCoin.call MetaCoin.constructor MetaCoin.toString
MetaCoin._constructorMethods MetaCoin._json MetaCoin._properties MetaCoin._property_values MetaCoin.abi
MetaCoin.addProp MetaCoin.address MetaCoin.arguments MetaCoin.at MetaCoin.bytecode
MetaCoin.caller MetaCoin.class_defaults MetaCoin.clone MetaCoin.contractName MetaCoin.contract_name
MetaCoin.currentProvider MetaCoin.deployed MetaCoin.ens MetaCoin.length MetaCoin.name
MetaCoin.new MetaCoin.parallel MetaCoin.prototype MetaCoin.setProvider MetaCoin.toJSON
MetaCoin.web3
valve(localhost_docker)> ConvertLib
ConvertLib
valve(localhost_docker)> ConvertLib.
ConvertLib.__defineGetter__ ConvertLib.__defineSetter__ ConvertLib.__lookupGetter__ ConvertLib.__lookupSetter__ ConvertLib.__proto__
ConvertLib.hasOwnProperty ConvertLib.isPrototypeOf ConvertLib.propertyIsEnumerable ConvertLib.toLocaleString ConvertLib.valueOf
ConvertLib.apply ConvertLib.bind ConvertLib.call ConvertLib.constructor ConvertLib.toString
ConvertLib._constructorMethods ConvertLib._json ConvertLib._properties ConvertLib._property_values ConvertLib.abi
ConvertLib.addProp ConvertLib.address ConvertLib.arguments ConvertLib.at ConvertLib.bytecode
ConvertLib.caller ConvertLib.class_defaults ConvertLib.clone ConvertLib.contractName ConvertLib.contract_name
ConvertLib.currentProvider ConvertLib.deployed ConvertLib.ens ConvertLib.length ConvertLib.name
ConvertLib.new ConvertLib.parallel ConvertLib.prototype ConvertLib.setProvider ConvertLib.toJSON
ConvertLib.web3
contract: MetaCoin.sol
pragma solidity >=0.4.25 <0.6.0;
import "./ConvertLib.sol";
// This is just a simple example of a coin-like contract.
// It is not standards compatible and cannot be expected to talk to other
// coin/token contracts. If you want to create a standards-compliant
// token, see: https://github.com/ConsenSys/Tokens. Cheers!
contract MetaCoin {
mapping (address => uint) balances;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
constructor() public {
balances[tx.origin] = 10000;
}
function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Transfer(msg.sender, receiver, amount);
return true;
}
function getBalanceInEth(address addr) public view returns(uint){
return ConvertLib.convert(getBalance(addr),2);
}
function getBalance(address addr) public view returns(uint) {
return balances[addr];
}
}
In the test directory, you can use/write javascript to test your contract.
cd test
node mc.js / mc_new.js
If you already have an address for a contract, you can create a new abstraction to represent the contract at that address.
MetaCoin.at("0x1234...").then(async function(instance) {
coin = instance;
..........
)}
example:
const ConfluxWeb = require('conflux-web');
var provider = new ConfluxWeb.providers.HttpProvider("http://0.0.0.0:12537");
var contractTr = require('valve-contract');
var MC = require("../build/MetaCoin.sol.json"); //Enter the actual path of the file compiled by your contract
const util = require('util');
const ad = "0xe1680683be13895b59c94eaf61818975a0d105dd";
const pk = "0x91594bd85fec9695a26ed630f536195b5f8c448560f46d68512e2efcd837d0ac";
var MetaCoin = contractTr({
contractName: "MetaCoin",
abi: MC.abi,
bytecode: MC.bytecode,
address: MC.contractAddress, // optional
});
MetaCoin.setProvider(provider);
var account_one = "0xe1680683be13895b59c94eaf61818975a0d105dd";
var account_two = "0x3ba790a9dcf7dd081f6167bc76a1e8279cb7da17";
var account_three = "0x49a583998b1921eded4f2ade09255648db7672d3";
// must be add this code,when you test you contract code
if (typeof MetaCoin.currentProvider.sendAsync !== "function") {
MetaCoin.currentProvider.sendAsync = function() {
return MetaCoin.currentProvider.send.apply(
MetaCoin.currentProvider,
arguments
);
};
}
var contract_address = MC.contractAddress;
var coin;
//coin.constructor.web3.cfx.accounts.wallet.add({
// privateKey: pk,
// address: ad
//});
MetaCoin.at(contract_address).then(async function(instance) {
coin = instance;
//console.log(util.inspect(coin, {
// showHidden: true,
// depth: 7
//}));
debugger
coin.getBalance("0xe1680683be13895b59c94eaf61818975a0d105dd").then(function(result) {
console.log("account_one balance is :", result)
console.log("--------------------------------")
coin.sendCoin(account_two, 3).then(async function(res) {
console.log("send account_two 3 coins result:", res) //0 is success, 1 or 2 is something is wrong
coin.getBalance(account_two).then(function(re) {
console.log("account_two balance is : ", re)
});
})
});
})
This function returns a Promise that resolves into a new instance of the contract abstraction at the newly deployed address.
you can find the example in the test directory.
......................
MetaCoin.new(....).then(async function(instance) {
coin = instance;
coin.getBalance("0xe1680683be13895b59c94eaf61818975a0d105dd").then(function(result) {
console.log("account_one balance is :", result)
console.log("--------------------------------")
coin.sendCoin(account_two, 3).then(async function(res) {
console.log("send account_two 3 coins result:", res) //0 is success, 1 or 2 is something is wrong
coin.getBalance(account_two).then(function(re) {
console.log("account_two balance is : ", re)
});
})
});
})
......................
Download Details:
Author: Conflux-Chain
Source Code: https://github.com/Conflux-Chain/conflux-valve
License:
#Conflux #blockchain #smartcontract
1593867420
Android Projects with Source Code – Your entry pass into the world of Android
Hello Everyone, welcome to this article, which is going to be really important to all those who’re in dilemma for their projects and the project submissions. This article is also going to help you if you’re an enthusiast looking forward to explore and enhance your Android skills. The reason is that we’re here to provide you the best ideas of Android Project with source code that you can choose as per your choice.
These project ideas are simple suggestions to help you deal with the difficulty of choosing the correct projects. In this article, we’ll see the project ideas from beginners level and later we’ll move on to intermediate to advance.
Before working on real-time projects, it is recommended to create a sample hello world project in android studio and get a flavor of project creation as well as execution: Create your first android project
Android Project: A calculator will be an easy application if you have just learned Android and coding for Java. This Application will simply take the input values and the operation to be performed from the users. After taking the input it’ll return the results to them on the screen. This is a really easy application and doesn’t need use of any particular package.
To make a calculator you’d need Android IDE, Kotlin/Java for coding, and for layout of your application, you’d need XML or JSON. For this, coding would be the same as that in any language, but in the form of an application. Not to forget creating a calculator initially will increase your logical thinking.
Once the user installs the calculator, they’re ready to use it even without the internet. They’ll enter the values, and the application will show them the value after performing the given operations on the entered operands.
Source Code: Simple Calculator Project
Android Project: This is a good project for beginners. A Reminder App can help you set reminders for different events that you have throughout the day. It’ll help you stay updated with all your tasks for the day. It can be useful for all those who are not so good at organizing their plans and forget easily. This would be a simple application just whose task would be just to remind you of something at a particular time.
To make a Reminder App you need to code in Kotlin/Java and design the layout using XML or JSON. For the functionality of the app, you’d need to make use of AlarmManager Class and Notifications in Android.
In this, the user would be able to set reminders and time in the application. Users can schedule reminders that would remind them to drink water again and again throughout the day. Or to remind them of their medications.
Android Project: Another beginner’s level project Idea can be a Quiz Application in android. Here you can provide the users with Quiz on various general knowledge topics. These practices will ensure that you’re able to set the layouts properly and slowly increase your pace of learning the Android application development. In this you’ll learn to use various Layout components at the same time understanding them better.
To make a quiz application you’ll need to code in Java and set layouts using xml or java whichever you prefer. You can also use JSON for the layouts whichever preferable.
In the app, questions would be asked and answers would be shown as multiple choices. The user selects the answer and gets shown on the screen if the answers are correct. In the end the final marks would be shown to the users.
Android Project: Tic-Tac-Toe is a nice game, I guess most of you all are well aware of it. This will be a game for two players. In this android game, users would be putting X and O in the given 9 parts of a box one by one. The first player to arrange X or O in an adjacent line of three wins.
To build this game, you’d need Java and XML for Android Studio. And simply apply the logic on that. This game will have a set of three matches. So, it’ll also have a scoreboard. This scoreboard will show the final result at the end of one complete set.
Upon entering the game they’ll enter their names. And that’s when the game begins. They’ll touch one of the empty boxes present there and get their turn one by one. At the end of the game, there would be a winner declared.
Source Code: Tic Tac Toe Game Project
Android Project: A stopwatch is another simple android project idea that will work the same as a normal handheld timepiece that measures the time elapsed between its activation and deactivation. This application will have three buttons that are: start, stop, and hold.
This application would need to use Java and XML. For this application, we need to set the timer properly as it is initially set to milliseconds, and that should be converted to minutes and then hours properly. The users can use this application and all they’d need to do is, start the stopwatch and then stop it when they are done. They can also pause the timer and continue it again when they like.
Android Project: This is another very simple project idea for you as a beginner. This application as the name suggests will be a To-Do list holding app. It’ll store the users schedules and their upcoming meetings or events. In this application, users will be enabled to write their important notes as well. To make it safe, provide a login page before the user can access it.
So, this app will have a login page, sign-up page, logout system, and the area to write their tasks, events, or important notes. You can build it in android studio using Java and XML at ease. Using XML you can build the user interface as user-friendly as you can. And to store the users’ data, you can use SQLite enabling the users to even delete the data permanently.
Now for users, they will sign up and get access to the write section. Here the users can note down the things and store them permanently. Users can also alter the data or delete them. Finally, they can logout and also, login again and again whenever they like.
Android Project: This app is aimed at the conversion of Roman numbers to their significant decimal number. It’ll help to check the meaning of the roman numbers. Moreover, it will be easy to develop and will help you get your hands on coding and Android.
You need to use Android Studio, Java for coding and XML for interface. The application will take input from the users and convert them to decimal. Once it converts the Roman no. into decimal, it will show the results on the screen.
The users are supposed to just enter the Roman Number and they’ll get the decimal values on the screen. This can be a good android project for final year students.
Android Project: Well, coming to this part that is Virtual Dice or a random no. generator. It is another simple but interesting app for computer science students. The only task that it would need to do would be to generate a number randomly. This can help people who’re often confused between two or more things.
Using a simple random number generator you can actually create something as good as this. All you’d need to do is get you hands-on OnClick listeners. And a good layout would be cherry on the cake.
The user’s task would be to set the range of the numbers and then click on the roll button. And the app will show them a randomly generated number. Isn’t it interesting ? Try soon!
Android Project: This application is very important for you as a beginner as it will let you use your logical thinking and improve your programming skills. This is a scientific calculator that will help the users to do various calculations at ease.
To make this application you’d need to use Android Studio. Here you’d need to use arithmetic logics for the calculations. The user would need to give input to the application that will be in terms of numbers. After that, the user will give the operator as an input. Then the Application will calculate and generate the result on the user screen.
Android Project: An SMS app is another easy but effective idea. It will let you send the SMS to various no. just in the same way as you use the default messaging application in your phone. This project will help you with better understanding of SMSManager in Android.
For this application, you would need to implement Java class SMSManager in Android. For the Layout you can use XML or JSON. Implementing SMSManager into the app is an easy task, so you would love this.
The user would be provided with the facility to text to whichever number they wish also, they’d be able to choose the numbers from the contact list. Another thing would be the Textbox, where they’ll enter their message. Once the message is entered they can happily click on the send button.
#android tutorials #android application final year project #android mini projects #android project for beginners #android project ideas #android project ideas for beginners #android projects #android projects for students #android projects with source code #android topics list #intermediate android projects #real-time android projects
1595547778
Developing a mobile application can often be more challenging than it seems at first glance. Whether you’re a developer, UI designer, project lead or CEO of a mobile-based startup, writing good project briefs prior to development is pivotal. According to Tech Jury, 87% of smartphone users spend time exclusively on mobile apps, with 18-24-year-olds spending 66% of total digital time on mobile apps. Of that, 89% of the time is spent on just 18 apps depending on individual users’ preferences, making proper app planning crucial for success.
Today’s audiences know what they want and don’t want in their mobile apps, encouraging teams to carefully write their project plans before they approach development. But how do you properly write a mobile app development brief without sacrificing your vision and staying within the initial budget? Why should you do so in the first place? Let’s discuss that and more in greater detail.
It’s worth discussing the significance of mobile app project briefs before we tackle the writing process itself. In practice, a project brief is used as a reference tool for developers to remain focused on the client’s deliverables. Approaching the development process without written and approved documentation can lead to drastic, last-minute changes, misunderstanding, as well as a loss of resources and brand reputation.
For example, developing a mobile app that filters restaurants based on food type, such as Happy Cow, means that developers should stay focused on it. Knowing that such and such features, UI elements, and API are necessary will help team members collaborate better in order to meet certain expectations. Whether you develop an app under your brand’s banner or outsource coding and design services to would-be clients, briefs can provide you with several benefits:
Depending on how “open” your project is to the public, you will want to write a detailed section about who the developers are. Elements such as company name, address, project lead, project title, as well as contact information, should be included in this introductory segment. Regardless of whether you build an in-house app or outsource developers to a client, this section is used for easy document storage and access.
#android app #ios app #minimum viable product (mvp) #mobile app development #web development #how do you write a project design #how to write a brief #how to write a project summary #how to write project summary #program brief example #project brief #project brief example #project brief template #project proposal brief #simple project brief template
1656131940
valve is an conflux framework which helps with Initialize a dapp project. inspird by truffle && ganache!
The framework makes the development of smart contracts in the conflux network pretty easy. It provides commands for compilation, deployment of smart contracts, running a local node, local compiler and unit testing the contracts.
valve consists of 5 separated packages. There are two main packages.
npm i -g conflux-valve
Before you start you must locally run a our conflux chain node. If you want to build by yourself, just fellow this: https://https://github.com/Conflux-Chain/conflux-docker
docker pull liqiazero/conflux-chain:v0.2.4
docker run --name conflux-chain -p 12537:12537 -p 32323:32323 -p 32323:32323/udp -p 14629:14629 -p 12539:12539 -d liqiazero/conflux-chain:v0.2.4
if u want use docker-compose, just following:
To start the network:
docker-compose up -d
To destroy the network:
docker-compose down
To cleanup the associated docker volumes, -v
option could be used:
docker-compose down -v
valve init
Put your own contract under the current directory
valve account
Generate account and private key .
You can find the generated wallet.json file in the current directory. All address, privatekey, publishkey will be written to this file.
The following content :
{
"wallet": [
{
"time": "2019-12-13 11:49:43",
"mnemonic": "accuse erosion version giant surprise hour course devote frozen cabbage birth fog",
"accounts": [
{
"address": "0xa7b4e98db3d570bd6cf01141dfc69a58b0eba3d7",
"publicKey": "0x3f2b115a74c0cecf197b8608d71890f3801c3ddc54bb5e50c2c83be9169b5c0224a70f5381a8c3ae2ea8065c476498c774b39f4093ecd6b687912d5ebd83452e",
"privateKey": "0x4270f5706de09280ff78cc91d3e02ce7a209538ce4fcf9b21d55196d5c89ac01"
},
{
"address": "0xd886f98626094a77d831a91ed15e2b0e2d463416",
"publicKey": "0xa3029052cd227709e2cdaefec0088a0248f00934bfe70022ec24c8b7f6bdd8c9de85b16a21632b536ca22f917eb3798c5b20644720667cd9bffe3fd7c12a5ec1",
"privateKey": "0xe5a0ddb5bae3cd7649981a5735c4eef3680969aa9e1852e0946e5313117f29d4"
},
{
"address": "0x297d58cc2f7bb0fd14c65e1b040d7c7d30f4db69",
"publicKey": "0x44c861480c5a0d45a8c56bbe95dac6ab933956d60e997c8acb866654a9584a4c47b77bc0f85ff031dfdce3df32318ad509ff5a1fbe71982e9a3030a1cea3b8aa",
"privateKey": "0x09a2975c885f4c9861c7cb4f9912b12c476fef35b9415e551d162143adfcc799"
},
{
"address": "0xd5ac5b46d4a1e18e41082e6e87939d38258dcd10",
"publicKey": "0x235a3e11267bf73dd652af3eea95eb7a757a535945a296a9f0c5c362f851f2335cec8beddaf51fd10c2ce88c760b2be1d2fd78537914b3fa473b6cd105fd4803",
"privateKey": "0xaa7197c6cac1950dd1ccef2f6af2372e4e66ea14f7b47f53ba25d7daa2f8d211"
},
{
"address": "0x93dccd823eb68f7739ab67990afeaf1b25729773",
"publicKey": "0x4610b40ada45976ae58d191ca8a7e0b088aa5148437bb1cb89c20d1c53587159721fd5301192bf44c6101e23d2b816f0c5c6ec7318933bf79d693b435310c461",
"privateKey": "0xfe4db093fecafb026396731e0489ce7d2263fb0958d7487c124985eabe173b5d"
},
{
"address": "0x5d38e928f2ed257a444a03fbc0fbf8e3eeb09fde",
"publicKey": "0x8a677fae9f146340641cf6d69b2ad7f474f4451ed41a1062c339eba4bf488f6ddf16bf663777ad4aadff592e9c062a0a2221d4fbc75349c5ab21ca02ffd72700",
"privateKey": "0xea337ea5dfca6f1e113f5cb0837987c88c089daa522234bea55d1dc77fd54eff"
},
{
"address": "0x1ecc9404876f127e422e06ad1ff4cd9d2a282ee4",
"publicKey": "0x205e612bf30e206f1509f93571a675c2d10a2d1330de4c85996edeafcaccb3d77aabe20c36c564eb32f7f39d66e60c7006c213f87ce26d17407f206a0925bdee",
"privateKey": "0xfbede3f6f97b625a692b45ef5bdc3ac03cdfe88ca00eb340b69f06e7aaa54904"
},
{
"address": "0x71fd598723355d0d3a25aed255a6075e5fa5394c",
"publicKey": "0x8a7599e25d4f073a99cc5f65bfb118c767d33be465da85af4b1087a3680286b30c4aa806abf491bb4c60f9ec051258feb57995be66a4ed8c50c21bda671be90c",
"privateKey": "0x4117984ea58a4741f068ef6e78844a74d6ff2a890cf2c5413b069e9d9ee64831"
},
{
"address": "0x79305dc2b3509212bb043befebb12a46d3cb190b",
"publicKey": "0xe18a6387b06092bb7cdfb56f18759a5088b748b0c1c0fb2618cff0ea024c0d5d50256b81e2e9f687ce6758864daafebe406bdab5a8ad71decf3afe15d9b239b6",
"privateKey": "0x556bbe7db0055f894179efe6bbbfa9274dfb2bbde8ca063113318fea435247c0"
},
{
"address": "0x9535ad60bf720baac2e8ab3a9308c46879241968",
"publicKey": "0xccb514ddafd7e6238923d4ea2f09a27b4f852a855d307efec938fb3c68862deb0058ccca8a799df360ca13cc1979117e2cbbc0f7180c5f57af08828a89e16da5",
"privateKey": "0x998340f60cbcb8b26b5cd3b851fc0546c2adf7daad6ac30ab1fb227424ade67f"
}
]
}
]
}
example:
valve compile
if you have multiple contracts, libraries, etc., there is a reference relationship between them. When compiling, valve will automatically do the linking for you. But you need to deploy your contracts in the order suggested.
.........
.........
-------------------------------------------- │
output: { contracts: │
{ 'ConvertLib.sol': { ConvertLib: [Object] }, │
'MetaCoin.sol': { MetaCoin: [Object] }, │
'Migrations.sol': { Migrations: [Object] } }, │
sources: │
{ 'ConvertLib.sol': { id: 0 }, │
'MetaCoin.sol': { id: 1 }, │
'Migrations.sol': { id: 2 } } }
U need first deploy this contract: [ 'ConvertLib.sol', 'Migrations.sol' ]
then deploy this contract: [ 'MetaCoin.sol' ]
To compile your contract, will generate build directory down generated abi and the bytecode.
Give your address some CFX coin.
example:
valve sendbalance --a "0xe1680683be13895b59c94eaf61818975a0d105dd"
default:
wallet addressIndex[0] as the default deploy address
Select the address and privatekey you want to deploy in the wallet.json file.
Ensure that your account has plenty of cfx coin, if not you can use valve sendbalance send some to your account.
example:
valve deploy --a "0xe1680683be13895b59c94eaf61818975a0d105dd" --pk "0x91594bd85fec9695a26ed630f536195b5f8c448560f46d68512e2efcd837d0ac" --name ConvertLib
Will be sent to test network related contracts over the contract.
If you are successful, you will receive the following log:
example:
you can find the transaction details on : http://www.confluxscan.io/transactionsdetail/0x5a8234da84f0c066780921a04b2cbc94d6e48a343cd9ae5bda5479d78a883f76
..............
Your contract has been deployed at :0xae2b17be6f7d590510fa7db89f86c02f55e73d2a
Home> valve console
commands: { compile:
{ command: 'compile',
description: 'compile contracts',
builder: {},
help: { usage: 'valve compile', options: [] },
run: [AsyncFunction: run] },
deploy:
{ command: 'deploy',
description: 'deploy contracts',
builder: {},
help: { usage: 'valve deploy', options: [] },
run: [AsyncFunction: run] },
sendbalance:
{ command: 'sendbalance',
description: 'send balance(30 cfx coin) to a address',
builder: {},
help: { usage: 'valve sendbalance', options: [] },
run: [AsyncFunction: run] },
account:
{ command: 'account',
description: 'generate address && priv
ate key',
builder: {},
help: { usage: 'valve account', options: [] },
run: [AsyncFunction: run] } }
valve(localhost_docker)> compile
start compile all the contracts, pls wait....
--------------------------------------------
output: { contracts:
{ 'ConvertLib.sol': { ConvertLib: [Object] },
'MetaCoin.sol': { MetaCoin: [Object] },
'Migrations.sol': { Migrations: [Object] } },
sources:
{ 'ConvertLib.sol': { id: 0 },
'MetaCoin.sol': { id: 1 },
'Migrations.sol': { id: 2 } } }
..................................
valve(localhost_docker)> cfx.
cfx.__defineGetter__ cfx.__defineSetter__ cfx.__lookupGetter__ cfx.__lookupSetter__
cfx.__proto__ cfx.hasOwnProperty cfx.isPrototypeOf cfx.propertyIsEnumerable
cfx.toLocaleString cfx.toString cfx.valueOf
cfx.Account cfx.Contract cfx.call cfx.close
cfx.constructor cfx.estimateGas cfx.getBalance cfx.getBestBlockHash
cfx.getBlockByEpochNumber cfx.getBlockByHash cfx.getBlockByHashWithPivotAssumption cfx.getBlocksByEpochNumber
cfx.getCode cfx.getEpochNumber cfx.getGasPrice cfx.getRiskCoefficient
cfx.getTransactionByHash cfx.getTransactionCount cfx.getTransactionReceipt cfx.setProvider
cfx.defaultEpoch cfx.defaultGas cfx.defaultGasPrice cfx.getLogs
cfx.provider cfx.sendRawTransaction cfx.sendTransaction
valve(localhost_docker)> cfx.defaultEpoch
'latest_state'
valve(localhost_docker)> cfx.defaultGas
1000000
valve(localhost_docker)> cfx.defaultGasPrice
100
valve(localhost_docker)> (await cfx.getBalance("0xe1680683be13895b59c94eaf61818975a0d105dd")).toString()
'199937499999800000000'
valve(localhost_docker)> MetaCoin.
MetaCoin.__defineGetter__ MetaCoin.__defineSetter__ MetaCoin.__lookupGetter__ MetaCoin.__lookupSetter__ MetaCoin.__proto__
MetaCoin.hasOwnProperty MetaCoin.isPrototypeOf MetaCoin.propertyIsEnumerable MetaCoin.toLocaleString MetaCoin.valueOf
MetaCoin.apply MetaCoin.bind MetaCoin.call MetaCoin.constructor MetaCoin.toString
MetaCoin._constructorMethods MetaCoin._json MetaCoin._properties MetaCoin._property_values MetaCoin.abi
MetaCoin.addProp MetaCoin.address MetaCoin.arguments MetaCoin.at MetaCoin.bytecode
MetaCoin.caller MetaCoin.class_defaults MetaCoin.clone MetaCoin.contractName MetaCoin.contract_name
MetaCoin.currentProvider MetaCoin.deployed MetaCoin.ens MetaCoin.length MetaCoin.name
MetaCoin.new MetaCoin.parallel MetaCoin.prototype MetaCoin.setProvider MetaCoin.toJSON
MetaCoin.web3
valve(localhost_docker)> ConvertLib
ConvertLib
valve(localhost_docker)> ConvertLib.
ConvertLib.__defineGetter__ ConvertLib.__defineSetter__ ConvertLib.__lookupGetter__ ConvertLib.__lookupSetter__ ConvertLib.__proto__
ConvertLib.hasOwnProperty ConvertLib.isPrototypeOf ConvertLib.propertyIsEnumerable ConvertLib.toLocaleString ConvertLib.valueOf
ConvertLib.apply ConvertLib.bind ConvertLib.call ConvertLib.constructor ConvertLib.toString
ConvertLib._constructorMethods ConvertLib._json ConvertLib._properties ConvertLib._property_values ConvertLib.abi
ConvertLib.addProp ConvertLib.address ConvertLib.arguments ConvertLib.at ConvertLib.bytecode
ConvertLib.caller ConvertLib.class_defaults ConvertLib.clone ConvertLib.contractName ConvertLib.contract_name
ConvertLib.currentProvider ConvertLib.deployed ConvertLib.ens ConvertLib.length ConvertLib.name
ConvertLib.new ConvertLib.parallel ConvertLib.prototype ConvertLib.setProvider ConvertLib.toJSON
ConvertLib.web3
contract: MetaCoin.sol
pragma solidity >=0.4.25 <0.6.0;
import "./ConvertLib.sol";
// This is just a simple example of a coin-like contract.
// It is not standards compatible and cannot be expected to talk to other
// coin/token contracts. If you want to create a standards-compliant
// token, see: https://github.com/ConsenSys/Tokens. Cheers!
contract MetaCoin {
mapping (address => uint) balances;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
constructor() public {
balances[tx.origin] = 10000;
}
function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Transfer(msg.sender, receiver, amount);
return true;
}
function getBalanceInEth(address addr) public view returns(uint){
return ConvertLib.convert(getBalance(addr),2);
}
function getBalance(address addr) public view returns(uint) {
return balances[addr];
}
}
In the test directory, you can use/write javascript to test your contract.
cd test
node mc.js / mc_new.js
If you already have an address for a contract, you can create a new abstraction to represent the contract at that address.
MetaCoin.at("0x1234...").then(async function(instance) {
coin = instance;
..........
)}
example:
const ConfluxWeb = require('conflux-web');
var provider = new ConfluxWeb.providers.HttpProvider("http://0.0.0.0:12537");
var contractTr = require('valve-contract');
var MC = require("../build/MetaCoin.sol.json"); //Enter the actual path of the file compiled by your contract
const util = require('util');
const ad = "0xe1680683be13895b59c94eaf61818975a0d105dd";
const pk = "0x91594bd85fec9695a26ed630f536195b5f8c448560f46d68512e2efcd837d0ac";
var MetaCoin = contractTr({
contractName: "MetaCoin",
abi: MC.abi,
bytecode: MC.bytecode,
address: MC.contractAddress, // optional
});
MetaCoin.setProvider(provider);
var account_one = "0xe1680683be13895b59c94eaf61818975a0d105dd";
var account_two = "0x3ba790a9dcf7dd081f6167bc76a1e8279cb7da17";
var account_three = "0x49a583998b1921eded4f2ade09255648db7672d3";
// must be add this code,when you test you contract code
if (typeof MetaCoin.currentProvider.sendAsync !== "function") {
MetaCoin.currentProvider.sendAsync = function() {
return MetaCoin.currentProvider.send.apply(
MetaCoin.currentProvider,
arguments
);
};
}
var contract_address = MC.contractAddress;
var coin;
//coin.constructor.web3.cfx.accounts.wallet.add({
// privateKey: pk,
// address: ad
//});
MetaCoin.at(contract_address).then(async function(instance) {
coin = instance;
//console.log(util.inspect(coin, {
// showHidden: true,
// depth: 7
//}));
debugger
coin.getBalance("0xe1680683be13895b59c94eaf61818975a0d105dd").then(function(result) {
console.log("account_one balance is :", result)
console.log("--------------------------------")
coin.sendCoin(account_two, 3).then(async function(res) {
console.log("send account_two 3 coins result:", res) //0 is success, 1 or 2 is something is wrong
coin.getBalance(account_two).then(function(re) {
console.log("account_two balance is : ", re)
});
})
});
})
This function returns a Promise that resolves into a new instance of the contract abstraction at the newly deployed address.
you can find the example in the test directory.
......................
MetaCoin.new(....).then(async function(instance) {
coin = instance;
coin.getBalance("0xe1680683be13895b59c94eaf61818975a0d105dd").then(function(result) {
console.log("account_one balance is :", result)
console.log("--------------------------------")
coin.sendCoin(account_two, 3).then(async function(res) {
console.log("send account_two 3 coins result:", res) //0 is success, 1 or 2 is something is wrong
coin.getBalance(account_two).then(function(re) {
console.log("account_two balance is : ", re)
});
})
});
})
......................
Download Details:
Author: Conflux-Chain
Source Code: https://github.com/Conflux-Chain/conflux-valve
License:
#Conflux #blockchain #smartcontract
1596992400
Starting something new is always difficult. When I working on my first coding project, I was wondering where to begin. I wondered what technologies I should use and whether I would come up with a good project idea. Today we will be going over my beginner’s guide to coding projects. I want to help you answer the same questions I asked myself when I worked on my first project. This will be especially helpful for people with little to no experience working on coding projects. If this post is helpful, please consider subscribing to my YouTube channel or check out my other articles for more content like this!
If you do not have any experience coding, that is completely fine! I recommend you take one of these free, online courses that will teach you the fundamentals of programming and a programming language: Java (commonly used to develop Android apps, web backends, etc.), Python (commonly used for data science and backend web development), HTML + CSS + JavaScript (used for frontend and backend web development).
I recommend mostly using technologies you are familiar with. You can use at most one or two new technologies. This will add some challenge to the project to encourage you to pick them up as you go, but will not overwhelm you such that you will not be able to make progress. In addition to establishing technologies, you also want to decide on the format of the project. This could be a web app, mobile app, database project, etc — this may also influence what technologies you need to use.
2. Come Up With an Idea
I recommend keeping things simple here. When I was working on my first project, I would keep questioning my ideas. I kept trying to build something innovative, but eventually, I understood that this was not the goal of the project. I should not judge the success of this project on how many users I have or whether I can build the next billion dollar company with it. The goal of this project is for you to learn and so long as you achieve that, the project is a success. Some common ideas for a first project include a personal website, simple mobile app, or following a tutorial and building on top of that.
3. Work on the Project
You need to find what motivates you to work on the project. You want to be working on it regularly. Also, you will inevitably get stuck trying to figure something out or debugging your project. It is important to remember that everyone faces this and that there are plenty of resources out there to help. For example, simply searching the question you have or the error message you received can yield answers. Websites such as Stack Overflow were built to allow the community to help coders who are encountering a blocker. Use these sites to get unblocked and you will be on your way to completing that project.
4. Share Your Project on GitHub
GitHub is a website that allows anyone to view and collaborate on open source projects. GitHub splits these up into repositories of files that make up the project itself. If you have never used git (a version control system) or GitHub, then I recommend reading this guide which will run you through the basics.
Once your project is complete, you should put up your project in one or more repositories on GitHub. This helps for two main reasons. First, you can easily share your projects with others. All it takes is sharing the link to your GitHub profile on your resume for recruiters, hiring managers, interviewers, and more to view your projects. Second, if you are working on a website, GitHub pages takes care of hosting the website for you. All you need to do is upload your files to a GitHub repository, set it up with GitHub pages, and your website will be published at .github.io.
I hope you found this story informative! Please share it with a friend you think might benefit from it as well! If you liked the post/video, feel free to like and subscribe to my YouTube account and check out my other articles for more content like this. Also, follow me on Twitter for updates on when I am posting new content and check me out on Instagram. I hope to see you all on the next one!
If you prefer to follow along via my YouTube video, you can watch it here!
#side-project #project-planning #programming #coding #side-projects #build-a-side-project #how-to-start-coding-projects #self-improvement
1619636760
Python is one of the most popular programming languages currently. It looks like this trend is about to continue in 2021 and beyond. So, if you are a Python beginner, the best thing you can do is work on some real-time Python project ideas.
We, here at upGrad, believe in a practical approach as theoretical knowledge alone won’t be of help in a real-time work environment. In this article, we will be exploring some interesting Python project ideas which beginners can work on to put their Python knowledge to test. In this article, you will find 42 top python project ideas for beginners to get hands-on experience on Python
Moreover, project-based learning helps improve student knowledge. That’s why all of the upGrad courses cover case studies and assignments based on real-life problems. This technique is ideally for, but not limited to, beginners in programming skills.
But first, let’s address the more pertinent question that must be lurking in your mind:
#data science #python project #python project ideas #python project ideas for beginners #python project topics #python projects #python projects for beginners