Skip to content

Commit

Permalink
Merge pull request #1 from OceanEx/dev
Browse files Browse the repository at this point in the history
Initial Public Release
  • Loading branch information
jiayuzhou authored May 29, 2019
2 parents e7e27e4 + 24843bb commit f6178e3
Show file tree
Hide file tree
Showing 19 changed files with 3,599 additions and 0 deletions.
158 changes: 158 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
node_modules
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/tasks.xml
.idea/**/dictionaries
.idea/**/shelf
.idea

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/
cmake-build-release/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests
### macOS template
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### VisualStudioCode template
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
# .env

# next.js build output
.next

dist

*.db
*.sqlite
*.sqlite3
.vscode
test.*
bins/
.env
12 changes: 12 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.vscode/
src/
test/
*.tgz
tsconfig.json
tslint.json
index.html
.nojekyll
coverage
.nyc_output
.travis.yml
tech-stack.png
98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
## Consistency Verification of Smart Contracts

Verify the consistency between the source code of a smart contract and its online `runtimeCode`.

### Install
```
npm install --save vscc
```

### Usage
#### Interface
```
interface IVerifyContract {
sourceCode: string, // base64 of contract source code
isOptimizer?: boolean, // whether optimizer (default: false)
contractAddress: string, // contract address
solcVersion?: string, // compiler version (default: solc version)
params?: string, // contract constructor params encode abi (default: '')
contractName: string, // contract name for compile
txId: string, // txid of deployed contract
runs?: string, // compiler runs (default 200)
}
```
### Example
#### Verify
```js
import { BlockChain, Utils, Vscc} from 'vscc'

const fs = require('fs')
const path = require('path')
const binPath = path.join(__dirname, './bins')

async function testVscc() {

if(!fs.existsSync(bins)) {
fs.mkdirSync(bins)
}

const soljson424 = '0.4.24'
const base64Code = Utils.encodeBase64('/*source code*/')
const c_addr = '/*contract address*/'
const txId = '/*txid*/'
const runs = '200'
const p = {
sourceCode: base64Code,
isOptimizer: false,
contractAddress: c_addr,
solcVersion: soljson424,
contractName: '/*contract name*/',
txId: txId,
runs: runs
}

try {
const ins = new Vscc('/*rpc endpoint*/', binPath)
// return true or false
const re = await ins.verify(p)
console.log('re: ', re)
} catch (error) {
console.log(error)
}
}
```
#### Download Compiler
If the target compiler does not exist, download it first.
```js
import { download } from 'vscc'

try {
await download(version, bins)
} catch (error) {
console.log(error)
}
```

### Methods
```
|--Vscc
| |--verify
|--BlockChain
| |--getCode
| |--deployContractOfCall
| |--accounts
| |--getTransaction
|--DownloadCompiler
| |--download
| |--getVersionList
|--Util
| |--decodeBase64
| |--encodeBase64
```

### References
- [ethereum solc-bin](https://github.com/ethereum/solc-bin)
- [solcjs](https://github.com/ethereum/solc-js)

### License
- GNU v3
Loading

0 comments on commit f6178e3

Please sign in to comment.