solpm
v0.1.6
Published
a small tool to clone and compile smart contracts
Downloads
2
Readme
solpm
solpm is a small tool to import solidiy contracts from github repositories and use them for your project. It also automatically configures the solc-js compiler to use with your project.
usage
installing solidity packages (= git repositories)
The command solpm --install
or solpm -i
will install all the dependencies listed in the "solidiy-package.json"-file.
CLI-Options:
-p
or--package
using a different solidity-package.json file-m
or--soliditymodule
using a different folder to extract the downloaded files to-y
or--autoApprove
automatically approves the deletion confirmation
Without any options provided spm will use the "solidity-package.json"-file in the root-directory of the project and will install all packages to a "solidity_modules" folder.
Caution At the beginning of the package-installation all files inside the solidity_modules folder will be deleted. If the directory already exists, you will have to confirm the deletion (unless you are using auto-approval).
Currently, spm only clones the git-repositories through https, so you will need an access-token set.
By default, spm will try to clone the branch set as default in git. With the addition of #BRANCHNAME
you can also specify a specific branch and spm will try to use the branch. If an error occurs it will fallback to the default branch.
example
solpm -i -p newSolidity-package.json -m importedContracts
will read the newSolidity-package.json-file and install the dependencies through git-clone to the importedContracts-folder (which will be created if not existing).
usage within smart contracts
After the installation of the solidity packages you can use them in your own smart contracts!.
example
You have a solidity-package.json file that looks like this:
{
"name": "ExampleUsage",
"dependencies": {
"example-usage-contracts": "https://github.com/..."
}
}
You can import all the contracts from this repositories in your own smart contracts with the command
import "example-usage-contracts/PATH_TO_SOLC_FILE";
The spm compiler will do the remapping by himself!
compiling
The command solpm --compile
or solpm -c
will try to compile the solidity contracts.
CLI-options
-s
or--source
changes the root-directory for the contracts to be compiles-t
or--target
changes the output directory for the compiled contracts-p
or--package
changes the solidity-package.json file-m
or--soliditymodule
changes the root-directy of the installed contract-packages-d
or--disableOptimizer
disables the solc-optimizer-r
or--optimizerRuns
changes the number of optimizer runs-y
or--autoApprove
automatically approves the deletion confirmation--save
writes the created solc-configuration file as "compilerConfig.json" to the root-directory--nowarnings
disables solc-compiler warnings (errors will still be shown)
spm will try to read the "solidity-package.json"-file (or the provided package name) and adjust the remappings automatically. For each contract it will create an own file with the
- abi
- bytecode
- deployedBytecode
- contractName
in the "contract-build" (or your target)-folder.
Caution At the beginning of the package-installation all files inside the output directory will be deleted. If the directory already exists, you will have to confirm the deletion (unless you are using auto-approval).
example
The command solpm -c -s myContractSource -t myCompileTarget -p mySolidity-package.json -m mySolidityModules -r 500 --save --nowarnings
will compile the all solidity files in myContractSource and its subdirectories and put the compiles JSON-files in the myCompileTarget folder. It will try to read the "mySolidity-package.json" file and create the remappings (found in the dependencies). It will also setup the compiler to do 500 runs, write the created solc-compiler config to the root-directory of the project and it will not show solc-compile-warnings (but errors).