
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
eth-new-contract
Advanced tools
eth-new-contract
is an npm module that allows you to deploy a Solidity contract and create a web3 contract instance straight from source. Subsequent calls use cached bytecode for performance.
The default new
method of web3 has the somewhat quirky behavior of invoking its callback twice—once to return the transaction hash and once when the contract is deployed. Usually you don't care about the transaction hash initially, so in this library, the promise resolves when it is deployed. contract.transactionHash
can then be accessed like on any web3 contract.
$ npm install --save eth-new-contract
const Web3 = require('web3')
const provider = new Web3.providers.HttpProvider('http://localhost:8545')
const web3 = new Web3(provider)
const newContract = require('eth-new-contract').default(provider)
// instantiate from source
const source = 'contract MyContract { function GetAnswer() constant returns(uint) { return 42; } }'
newContract(source, { from: web3.eth.accounts[0] })
.then(contract => {
console.log('Contract deployed at ' + contract.address)
})
You can also compile and generate the web3 constructor yourself and pass it to eth-new-contract
:
const solc = require('solc')
const Web3 = require('web3')
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
const newContract = require('eth-new-contract').default() // no provider needed
// compile contract
const compilation = solc.compile(contractSource)
const bytecode = compilation.contracts[contractName].bytecode
const abi = JSON.parse(compilation.contracts[contractName].interface)
const MyContract = web3.eth.contract(abi)
// deploy
newContract(MyContract, { from: web3.eth.accounts[0], data: bytecode })
.then(contract => {
console.log('Contract deployed at ' + contract.address)
})
bip39
incompatibility with testrpc requires explicit dependency version: https://github.com/ethereumjs/testrpc/issues/313#issuecomment-304790839ISC © Raine Revere
FAQs
Deploy Solidity contracts straight from source.
We found that eth-new-contract demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.