Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
@requestnetwork/request-network.js
Advanced tools
A JavaScript library for interacting with the Request Network protocol
Welcome to the requestNetwork.js documentation! requestNetwork.js is a Javascript library for interacting with the Request Network protocol. Using the library you can create new requests from your applications, pay them, consult them or update them from your own off-chain applications.
If your application is decentralized and onchain on Ethereum, you can directly interact with our smart contracts. Smart contract documentation
This is still an alpha version which will evolve significantly before the main net release.
Everything that is specified in the wiki.
Among other things, this documentation specifies the smart contract architecture, the different actions that can be done at specific times, the statuses, how to use the extensions, the fee management system, the cross currency feature, how to manage identity and what to expect from the reputation system.
No tutorials available yet. Feel free to suggest yours and we will refer to it. If you’re looking for an example, you can browse the app.request.network website and github
requestNetwork.js ships as a CommonJS package. CommonJS (recommended):
npm install @requestnetwork/request-network.js --save
yarn add @requestnetwork/request-network.js
(We are currently working on retrieving the name of requestnetwork.js)
import RequestNetwork from '@requestnetwork/request-network.js';
npm install -g ganache-cli
Launch a ganache-cli instance on a terminal:
npm run ganache
In a second terminal, Launch an ipfs node:
ipfs daemon
In a third terminal, deploy the contracts:
npm run testdeploy
You can now launch the unit tests:
npm run testunit
Default configuration (Infura and Rinkeby)
let requestNetwork = new RequestNetwork();
Custom configuration
let requestNetwork = new RequestNetwork(provider, networkId, useIpfsPublic);
Instantiates a new RequestNetwork instance that provides the public interface to the requestNetwork.js library.
@param provider
The Web3.js Provider instance you would like the requestNetwork.js library to use for interacting with the Ethereum network.
@param networkId
the Ethereum network ID.
@param useIpfsPublic
use public ipfs node if true, private one specified in “src/config.json ipfs.nodeUrlDefault.private” otherwise
@return An instance of the requestNetwork.js RequestNetwork class.
requestNetwork.js is a promise-based library. This means that whenever an asynchronous call is required, the library method will return a native Javascript promise. You can therefore choose between using promise or async/await syntax when calling our async methods.
Every function that modify data on the blockchain will trigger first an event “broadcasted” when the transaction is submitted to the nodes, before returning the request data when the transaction is confirmed. You can specify a number of confirmations to wait before returning the promise in options.numberOfConfirmation - default to 0.
Async/await syntax (recommended):
try {
var data = await requestNetwork.requestEthereumService.accept(requestId).on('broadcasted', txHash => {
//Transaction broadcasted
console.log('transaction hash: ', txHash);
});
//Transaction mined
console.log(data.request)
} catch (error) {
console.log('Caught error: ', error);
}
Promise syntax:
requestNetwork.requestEthereumService.accept(requestId).on('broadcasted', txHash => {
//Transaction broadcasted
console.log('Transaction hash: ', txHash);
}).then(data => {
//Transaction mined
console.log(data.request);
})
.catch(error => {
console.log('Caught error: ', error);
});
As is the convention with promise-based libraries, if an error occurs, it is thrown. It is the callers responsibility to catch thrown errors and to handle them appropriately.
The library adheres to the Semantic Versioning 2.0.0 specification. Note that major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable since the library is still an alpha and we will introduce backward incompatible changes to the interface without incrementing the major version until the 1.0.0 release. Our convention until then will be to increment the minor version whenever we introduce backward incompatible changes to the public interface, and to increment the patch version otherwise. Functions
public createRequestAsPayee(_payer: string, _amountInitial: any, _data ? : string, _extension ? : string, _extensionParams ? : Array < any >, _options ? : any)
Emit the event 'broadcasted'
with {transaction: {hash}}
when the transaction is submitted.
_payer
address of the payer_amountInitial
amount initial expected of the request_data
Json of the request's details (optional)_extension
address of the extension contract of the request (optional) NOT USED YET_extensionParams
array of parameters for the extension (optional) NOT USED YET_options
options for the method (gasPrice
, gas
, value
, from
, numberOfConfirmation
){request, transaction}
)public createRequestAsPayer(_payee: string, _amountInitial: any, _additionals: any, _data ? : string, _extension ? : string, _extensionParams ? : Array < any >, _options ? : any)
Emit the event 'broadcasted'
with {transaction: {hash}}
when the transaction is submitted.
_payee
address of the payee_amountInitial
amount initial expected of the request_amountToPay
amount to pay in wei_additionals
additional to declaire in wei (optional)_data
Json of the request's details (optional)_extension
address of the extension contract of the request (optional) NOT USED YET_extensionParams
array of parameters for the extension (optional) NOT USED YET_options
options for the method (gasPrice
, gas
, value
, from
, numberOfConfirmation
){request, transaction}
)public signRequestAsPayee(_amountInitial: any, _amount: any, _additionals: any, _data ? : string, _extension ? : string, _extensionParams ? : Array < any >, _options ? : any)
_amountInitial
amount initial expected of the request_expirationDate
timestamp of the date after what the signed request is useless_data
Json of the request's details (optional)_extension
address of the extension contract of the request (optional) NOT USED YET_extensionParams
array of parameters for the extension (optional) NOT USED YET_from
address of the payee, default account will be used otherwise (optional)public broadcastSignedRequestAsPayer(_signedRequest: any, _amountToPay: any, _additionals: any, _options ? : any)
Emit the event 'broadcasted'
with {transaction: {hash}}
when the transaction is submitted.
_signedRequest
object signed request (see Signed Request)_amountToPay
amount to pay in wei (optional)_additionals
additional to declaire in wei (optional)_options
options for the method (gasPrice, gas, value, from, numberOfConfirmation){ "amountInitial" => Amount initial of the request "currencyContract": => Address of the currency contract "data": => hash of the ipfs file (optional) "expirationDate": => unix timestamp of expiration date (in second) "hash": => solidity hash of the request data "payee": => payee address (which must be the signer also) "signature": => signature by payee of the hash }
Example:
{ "amountInitial":"100000000", "currencyContract":"0xf12b5dd4ead5f743c6baa640b0216200e89b60da", "data":"QmbFpULNpMJEj9LfvhH4hSTfTse5YrS2JvhbHW6bDCNpwS", "expirationDate":7952342400, "hash":"0x45ba3046df9e10f5b32c893ad21749d69c473d6629756654f82b9528da6c1480", "payee":"0x821aea9a577a9b44299b9c15c88cf3087f3b5544", "signature":"0x6df09d4c90bafea043d555caeb3d01d2dc656df2e27741b2b7f66403a682c69070d3ba30119598b766e5eb6413d49d6d91c349e23207b96102f54c69fca967d800" }
public accept(_requestId: string, _options ? : any)
Emit the event 'broadcasted'
with {transaction: {hash}}
when the transaction is submitted.
_requestId
requestId of the payer_options
options for the method (gasPrice
, gas
, value
, from
, numberOfConfirmation
){request, transaction}
)public cancel(_requestId: string, _options ? : any)
Emit the event 'broadcasted'
with {transaction: {hash}}
when the transaction is submitted.
_requestId
requestId of the payer_options
options for the method (gasPrice
, gas
, value
, from
, numberOfConfirmation
){request, transaction}
)public paymentAction(_requestId: string, _amount: any, _additionals: any, _options ? : any)
Emit the event 'broadcasted
' with {transaction: {hash}}
when the transaction is submitted.
_requestId
requestId of the payer_amount
amount to pay in wei_additionals
additional to declaire in wei (optional)_options
options for the method (gasPrice
, gas
, value
, from
, numberOfConfirmation
){request, transaction}
)public refundAction(_requestId: string, _amount: any, _options ? : any)
Emit the event 'broadcasted'
with {transaction: {hash}}
when the transaction is submitted.
_requestId
requestId of the payer_amount
amount to refund in wei_options
options for the method (gasPrice
, gas
, value
, from
, numberOfConfirmation
){request, transaction}
)public subtractAction(_requestId: string, _amount: any, _options ? : any)
Emit the event 'broadcasted'
with {transaction: {hash}}
when the transaction is submitted.
_requestId
requestId of the payer_amount
subtract to declare in wei_options
options for the method (gasPrice
, gas
, value
, from
, numberOfConfirmation
){request, transaction}
)public additionalAction(_requestId: string, _amount: any, _options ? : any)
Emit the event 'broadcasted' with {transaction: {hash}} when the transaction is submitted.
_requestId
requestId of the payer_amount
subtract to declare in wei_options
options for the method (gasPrice
, gas
, value
, from
, numberOfConfirmation
){request, transaction}
)public getRequestCurrencyContractInfo(_requestId: string)
return {}
always
_requestId
requestId of the request{}
here)requestCoreServices.getRequest()
)public getRequest(_requestId: string)
_requestId
requestId of the requestpublic getRequestByTransactionHash(_hash: string)
Get a request and method called by the hash of a transaction
requestCoreServices.getRequestEvents()
)public getRequestEvents(_requestId: string, _fromBlock ?: number, _toBlock ?: number)
_requestId
requestId of the request_fromBlock
search events from this block (optional)_toBlock
search events until this block (optional)public getRequestEventsCurrencyContractInfo(_requestId: string, _fromBlock ?: number, _toBlock ?: number)
@param _requestId
requestId of the request
@param _fromBlock
search events from this block (optional)
@param _toBlock
search events until this block (optional)
@return promise of the object containing the events from the currency contract of the request (always {}
here)
Here is the list of events produced by the Request Network smarts contracts. Note that the solidity types will be converted in strings when you receive them.
Created(bytes32 indexed requestId, address indexed payee, address indexed payer)
Accepted(bytes32 indexed requestId)
Canceled(bytes32 indexed requestId)
UpdateBalance(bytes32 indexed requestId, int256 deltaAmount)
UpdateExpectedAmount(bytes32 indexed requestId, int256 deltaAmount)
NewPayee(bytes32 indexed requestId, address payee)
NewPayer(bytes32 indexed requestId, address payer)
NewExpectedAmount(bytes32 indexed requestId, int256 expectedAmount)
NewExtension(bytes32 indexed requestId, address extension)
NewData(bytes32 indexed requestId, string data)
FAQs
A JavaScript library for interacting with the Request Network protocol
The npm package @requestnetwork/request-network.js receives a total of 1 weekly downloads. As such, @requestnetwork/request-network.js popularity was classified as not popular.
We found that @requestnetwork/request-network.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.