Ethereum client web3j
If you want to query the transaction records on the main network, you can use Etherscan. However, if you build your own private chain, how should you query the transaction records
the answer is that you need to listen to the logs on the chain, save them in the database, and then query them in the database. For example:
< pre t = "code" L = "Java" > varaddr = & quot& quot;< br />varfilter=web3.eth.filter({fromB lock:0 ,toBlock:' latest', address:addr });< br />filter.get(function(err,transactions){transactions.forEach(function(tx){
vartxInfo=web3.eth.getTransaction(tx.transactionHash);
/ / at this time, the transaction information txinfo can be stored in the database
})< br />}); Pre >
Web3. Eth. Filter() is used to monitor the log on the chain, and Web3. Eth. Gettransaction() is used to extract the information of the specified transaction. Once the transaction information is obtained, it can be stored in the database for query
recommend a practical introction, you can see: Ethereum tutorial
Blockchain projects require high efficiency, so most of the core source code development is using C / C + +. However, if you are doing a blockchain project, unless you need to make a lot of adjustments to the source code, you may not choose to use Java. For general DAPP applications, java development should also be a good choice. For example, in the case of Ethereum blockchain, there is a web3j class library for Java, which is very convenient; Bitcoin has bitcoin J class library, which is also easy to use. It still depends on the level of application, what to do, and the situation of the team
share two Java blockchain tutorials:
-
java bitcoin details
-
java Ethereum development
< / OL >
#import "ViewController.h"
@implementation ViewController
-(void)aaa:(UIButton *)btn
{
NSString *method=[NSString stringWithFormat:@"login"];
NSString *username=[NSString stringWithFormat:@"123"];
笭肠蒂段郦灯垫犬叮华 NSString *password=[NSString stringWithFormat:@"123"];
NSString *urlString= [NSString stringWithFormat:@"",@"method=",method,@"username=",username,@"password=",password];
ASIFormDataRequest *requestForm = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:urlString]];
//设置需要POST的数据,这里提交两个数据,A=a&B=b
//[requestForm setPostValue:@"a" forKey:@"A"];
//[requestForm setPostValue:@"b" forKey:@"B"];
[requestForm startSynchronous];
//输入返回的信息
NSLog(@"response\n%@",[requestForm responseString]);
[requestForm release];
}
- (void)viewDidLoad
{
[super viewDidLoad];
button1=[[UIButton alloc]initWithFrame:CGRectMake(200, 200, 50, 50)];
button1.backgroundColor=[UIColor redColor];
[self.view addSubview:button1];
[button1 addTarget:self action:@selector(aaa:) forControlEvents:UIControlEventTouchUpInside];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL):(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != );
}
@end
客户端想要访问服务器
必须加上服务器的ip 服务端我是这样实现的
服务器是用java开发的
public
void doLogin(HttpServletRequest request,HttpServletResponse response) throws
IOException{
String
username=request.getParameter("username");
String
password=request.getParameter("password");
String
getStr=request.getParameter("A");
System.out.println("用户名:"+username+
"密码:"+password);
getAddr(request);
PrintWriter
out=response.getWriter();
String msg=null;
if(username!=null&&username.equals("123")&&password!=null
&&password.equals("123")&&
getStr!=null&&getStr.equals("a")){
msg="登陆成功";
}
else
{
msg="登陆失败";
}
out.print(msg);
out.flush();
out.close();
}
the working principle of nativscript: calling native API with JavaScript to realize cross platform
nativscript is a cross platform solution recently launched, which allows you to directly write Android and IOS local applications with JavaScript, It will be extended to Windows platform in the future. It's a project that has received more attention recently. It is essentially different from NW (formerly known as node WebKit, using web to write winodw / Linux desktop application) and phonegap embedded WebView to write app. It calls the system native API directly with JavaScript, so it has some native application characteristics.