Java使用web3j调用智能合约
时间: 2020-03-23来源:OSCHINA
前景提要
【围观】麒麟芯片遭打压成绝版,华为亿元投入又砸向了哪里?>>>
1.Java程序引入相关依赖,后面用于调用智能合约中的函数 <!-- https://mvnrepository.com/artifact/org.web3j/core --> <dependency> <groupId>org.web3j</groupId> <artifactId>core</artifactId> <version>4.5.15</version> </dependency> <!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp --> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>4.4.0</version> </dependency> <!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp-ws --> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp-ws</artifactId> <version>3.4.2</version> </dependency>
2.将合约使用 remix 进行编译

编译后,复制abi、Bytecode,放入指定位置,生成abi和bin文件
@Test void generateABIAndBIN() { String abi = ""; String bin = ""; String abiFileName = "AWMain.abi"; String binFileName = "AWMain.bin"; File abiFile = new File("E:\\solidity\