For now, it works just like a scanner that works just like the marketplace filter, wraped in python.
The idea for the future is to extend and modularize, allowing you to write purchase scripts. For example: keep looking for a gold beard topaz with a price below 0.05. If found, send it to the automatic purchase module.
Contributions in that regard are totally welcome, please fork me.
For now, t
Usage
usage: pyrrrscanner.py [-h] [-gen GEN] [-p MAX_PRICE] [-mp MIN_PRICE] [-v]
[-go] [-s] [-c CATTRIBUTES] [-color MAIN_COLOR]
[-k KITTY]
prrrruuscanner - cryptokitties.co (CK) scanner, build with pruu love by nelown
optional arguments:
-h, --help show this help message and exit
-gen GEN, --gen GEN Cryptokittie generation(s) to search for. Ex: -gen 1,
-gen 1,3,5
-p MAX_PRICE, --max_price MAX_PRICE
Top price filter, set the maximum price here
-mp MIN_PRICE, --min_price MIN_PRICE
The minium price filter.
-v, --virgin True if you are looking for virgins kitties, falsle
otherwise
-go, --goodies_only Check for the best cattributes only
-s, --sire Search for siring auctions instead of selling.
-c CATTRIBUTES, --cattributes CATTRIBUTES
Search for informed cattributes only. Same format as
-gen
-color MAIN_COLOR, --main_color MAIN_COLOR
Search for informed main color only. Same format as
-gen
-k KITTY, --kitty KITTY
Retrieve all kitty info
Example
Searching for a gen3 cymric beard:
python pyrrrscanner.py -gen 3 -c cymric,beard
prrrruuscanner - cryptokitties.co (CK) scanner, build with pru by nelown
Feel free to donate some kitties :) 0xccAb13D1e0430b11213a385223423eb4Fe18A129
[*] Scanner init
[*] QuerySearch Config: "
|_ gen: 3
|_ maxPrice: 1.0
|_ minPrice: 0.0
|_ virgin: False
|_ goodies: False
|_ sire: False
|_ cattributes: ['cymric', 'beard']
|_ mainColor: [],
|_ cooldownMaxIndex: 10
[*] Scanner starting
(...)
[Kitty 145590]
|_ name: None
|_ gen: 3
|_ virgin: True
|_ color: mintgreen
|_ born: 2017-12-08T06:33:36.000Z
|_ catributes: ['orangesoda', 'chocolate', 'thicccbrowz', 'beard', 'mintgreen', 'totesbasic', 'emeraldgreen', 'cymric']
|_ is ready: True
|_ cooldown index: 1
|_ cooldown: 1442287584405
|_ price: 0.113717
(...)
[SCANNER] Shutting down.
[SCANNER] Found 7 kitties that match parameters.
[SCANNER] median price for this search: 0.406399
[112096] ETH 1.000000 - https://www.cryptokitties.co/kitty/112096
[121290] ETH 0.140000 - https://www.cryptokitties.co/kitty/121290
[101661] ETH 0.550000 - https://www.cryptokitties.co/kitty/101661
[145590] ETH 0.113717 - https://www.cryptokitties.co/kitty/145590
[159387] ETH 0.473263 - https://www.cryptokitties.co/kitty/159387
[98716] ETH 0.126127 - https://www.cryptokitties.co/kitty/98716
[148349] ETH 0.441688 - https://www.cryptokitties.co/kitty/148349
Search for any kitty that has color gold, beard and chocolate as cattributes and costs less than 0.05 eth:
python g.py -s -p 0.05 -color gold -c beard,chocolate
[*] Scanner init
[*] QuerySearch Config: "
|_ gen:
|_ maxPrice: 10.0
|_ minPrice: 0.0
|_ virgin: False
|_ goodies: False
|_ sire: True
[*] Scanner starting
[*] Scan offset configs
|_ offset: 0
|_ limit: 50
[CryptokittieAPI] - Getting auctions: https://api.cryptokitties.co/auctions?offset=0&limit=50&type=sire&status=open&sorting=young&orderBy=current_price&orderDirection=asc&search=+beard+chocolate+gold
[SCANNER] Got a total of 1 auctions.
[CryptokittieAPI] Getting kitty 128521: https://api.cryptokitties.co/kitties/128521
[SELECTOR 128521] Scanning for desired cattributes.
[SELECTOR 128521] Found chocolate.
[SELECTOR 128521] Found beard.
[SELECTOR 128521] Found gold as main color
[*] Total found so far: 1
[Kitty 128521]
|_ name: Gold Mauveover
|_ gen: 4
|_ virgin: False
|_ color: gold
|_ born: 2017-12-07T13:07:05.000Z
|_ catributes: ['luckystripe', 'granitegrey', 'chocolate', 'munchkin', 'thicccbrowz', 'beard', 'mauveover', 'gold']
|_ price: 0.085000
Search for any gen 2 or 3 virgin kitty, costing less than 0.05 eth:
python pyrrrscanner.py -gen 2 -v -p 0.005
You can also search for siring gold gen2 costing les .005:
Inside the app.py there are a method to apply over the class instance too.
Take a look in the code comments to understand the logic
# app.pyimportlib# inside lib has a method bar with the attribute email definitionfrompycheckoimportPychecko# There is another method bar with a different definition to the attribute emaildefbar(self):
self.email='bar@email.com'# Class A definitionclassA:
def__init__(self, first_name, last_name):
# There are just two attributesself.first_name=first_nameself.last_name=last_name# And just the method foodeffoo(self):
print('{first_name} {last_name}: {email}'.format(
first_name=self.first_name,
last_name=self.last_name,
email=self.email)) # There is a attribute that is defined just in the bar# the main logicif__name__=='__main__':
# Instantiate the class Aa=A('FirstName', 'LastName')
# pass the instance variable to PyCheckopycheck=Pychecko(a)
# Add the methods that you want applypycheck.add(
bar,
[a.first_name=='FirstName', a.last_name=='LastName'] # Two bool conditions
)
pycheck.add(
lib.bar,
[a.first_name!='FirstName'ora.last_name!='LastName'] # One bool condition
)
# running PyChecko and get the modified instancea=pycheck.executea.bar()
a.foo() # The result will be: FirstName LastName: 'bar@email.com'
Pychecko with bulk insert
# app.pyfrompycheckoimportPychecko# Method bar definition outside the classdefbar(self):
self.email='bar@email.com'# Method foo definition outside the classdeffoo(self):
print('{first_name} {last_name}: {email}'.format(
first_name=self.first_name,
last_name=self.last_name,
email=self.email)) # attribute that is defined just in the bar# Class A definitionclassA:
def__init__(self, first_name, last_name):
# There are just two attributesself.first_name=first_nameself.last_name=last_name# the main logicif__name__=='__main__':
# Instantiate the class Aa=A('FirstName', 'LastName')
# pass the instance variable to PyCheckopycheck=Pychecko(a)
# Add the methods that you want apply# Two bool conditionspycheck.bulk_add(
[
bar,
foo,
]
[True]
)
# running PyChecko and get the modified instancea=pycheck.executea.bar()
a.foo() # The result is: FirstName LastName: 'bar@email.com'
Pychecko Using Classes
frompycheckoimportPycheckoComponent# Creating a pycheko componentclassMyComponentA(PycheckoComponent):
# is_applied is required for the PychecoComponents# It's responsible to identify if all class methods# should be applied in an instancedefis_applied(self):
returnTruedefbar(self):
self.email='john.doe@email.com'classMyComponentB(PycheckoComponent):
defis_applied(self):
returnTruedefname_changer(self):
self.first_name='john doe'
# app.pyimportlib# inside lib has a method bar with the attribute email definitionfrompycheckoimportPycheckoClassModifier# There is another method bar with a different# definition to the attribute emaildefbar(self):
self.email='bar@email.com'# Class A definitionclassA:
def__init__(self, first_name, last_name):
# There are just two attributesself.first_name=first_nameself.last_name=last_name# And just the method foodeffoo(self):
print('{first_name} {last_name}: {email}'.format(
first_name=self.first_name,
last_name=self.last_name,
email=self.email)) # attribute that is defined just in the bar# the main logicif__name__=='__main__':
# Instantiate the class Ainstance=A('FirstName', 'LastName')
# pass the instance variable to PyCheckoClassModifier# whit the classes that should be appliedpycheck=PycheckoClassModifier(instance, [
lib.MyComponentA(), # This implements bar()lib.MyComponentB(), # This implements name_changer()
])
# running PyChecko and get the modified instancea=pycheck.executea.bar()
a.name_changer()
a.foo() # The result is: John Doe LastName: 'bar@email.com'
Applying instance validation
Another possible option is validate the instance integrity.
# app.py'''create a list with the name methods that must bein the instance after execute the Pychecko'''instance_signature [
'method_a',
'method_b',
'method_c',
]
# In the Pychecko declaration, send the list in the optional parametera=A('value1', 'value2')
pycheck=Pychecko(a, signature=instance_signature)
# ...'''At final, if all methods that you sent in the listto Pychecko are in the instance, the instance will be returnedusing the `execute` property.If the instance does't respect the signature will the thrown theException InvalidSignatureClassError'''a=pycheck.execute# ...
The code for the paper:
Backtracking, Interleaving, and Terminating Monad Transformers
(Functional Pearl)
ICFP 2005.
Copyright (c) 2005, Amr Sabry, Chung-chieh Shan, Oleg Kiselyov,
and Daniel P. Friedman
The code has been tested with GHC 6.2.2 and 6.4, and 6.10
The overview of the files
Logic Monad Transformer: MonadPlusT with interleave, bindi, ifte and once
MCPT.hs -- LogicT sample code
In particular: Missionaries and cannibals problem
TicTacToe.hs -- An extended example: Tic-Tac-Toe with minimax search
and two heuristics (heavily based on the code by
Andrew Bromage)
LogicT.hs -- Definition, and implementation of
generic operations in terms of msplit
SFKT.hs -- Implementation of LogicT based on the two-continuation
model of streams
SRReifT.hs -- Direct-style implementation of LogicT, using
first-class delimited continuations
Requires the CC library:
http://okmij.org/ftp/continuations/CCmonad/
Standalone Logic Monad: MonadPlus with interleave, bindi, ifte and once
LogicM.hs -- Definition, and implementation of
generic operations in terms of msplit
SFK1.hs -- Implementation of LogicM based on two-continuation
model of streams
ListLM.hs -- Implementation of LogicM with streams modeled as
(lazy) lists
Last updated: September 2010.
GitHub Profile Finder es una aplicación desarrollada con React que permite a los usuarios buscar perfiles de GitHub y explorar información detallada sobre ellos, incluyendo sus repositorios públicos.
🖥️ Visualización
Página de inicio
Repositorios del usuario
⚙️ Características principales
Búsqueda de usuarios de GitHub:
Nombre del usuario.
Descripción del perfil.
Localización.
Fecha de creación de la cuenta.
Número total de repositorios.
Seguidores y seguidos.
Es posible visitar el perfil del usuario en la página oficial de Github mediante un botón de visita de perfil
📁 Exploración de repositorios:
Muestra una lista de repositorios con información relevante:
Nombre del repositorio
Descripción
Etiquetas
Homepage
Lenguaje principal
Licencia
Accede a los detalles del repositorio:
Enlace directo al repositorio en GitHub.
Enlace a la homepage si el repositorio la tiene configurada.
📜 Paginación o carga diferida:
El componente InfiniteScroll fue utilizado para mostrar los repositorios de manera parcial, es decir que solamente se mostrarán conforme el usuario avance, esto con el objetivo de no cargar toda la información de manera incial, evitando tiempos de carga prolongados cuando un usuario tiene una gran cantidad de repositorios
Los primeros 10 repositorios se cargan inicialmente.
Carga más repositorios al hacer scroll hacia abajo.
Oakland is rapidly changing. The city and its residents are making decisions today that will shape life in Oakland for years. The community is motivated to ensure the city’s development reflects their values and creates the lifestyle they want, but they don’t have a way to see the impact of development choices on their neighborhoods.
Mission
Project Urban Graph (PUG) provides a framework for Oakland’s communities to quantify and visualize the effects of new urban developments on transportation, sustainability, and civic life at large.
Impact
When we say graph, we are using the definition used in math: a network of things (nodes) and the connections between them (edges). Everything in a city is connected, after all. By structuring open-source city data as a graph, we can answer simple questions like:
What is the most well-lit path from point A to point B?
What is the path with the most trees from point A to point B?
What is the average distance to every bus stop less than 5’ away from point A?
What is the average distance to every park less than 5’ away from point A?
As well as more complex questions like:
How does the new shopping center affect traffic along Broadway Street?
Where do we need more parking to accommodate residents of the new apartment building?
Does increased lighting along Grand Avenue reduce crime rates in the area?
The Chainweb Mining Client (CMC) is the middle man between your ASIC and a Kadena node. CMC gets work from a node and submits the solved work (shares / blocks) to a Kadena node.
Official releases of CMC don’t have a compiled binary. I have compiled the released code into an executable for Ubuntu and Windows. My goal is to continue to release binaries for the chainweb-mining-client if official releases don’t have them. In other words, I will discontinue compiling binaries only if official releases have them for download.
I have tested the compiled binaries in this repository to make sure they work as intended.
If I make any changes to the source code before compiling, I will note that. For example, I compiled a binary that beeps your computer speaker whenever a block is found. The beeping functionality is not present in the official release. I will compile official releases with zero modification and I will compile one with the “beep”.
How to install / use
Download your preferred binary release from this repo
Extract the file to a directory/folder — /mining-client for example
Start the mining client with the command below.
Be aware that you would need a synced Kadena node to be able to use CMC. Well, you can use it even without a synced node, but it will be useless because you’ll be solving blocks that have been mined. Additionally, you would need to whitelist your Kadena k:account / key on the node you plan to mine on / to (read about Kadena Solo Miners Collective below). Remember, CMC is just the middleman (stratum) receiving work from a node and submitting solved work back to the node.
You can issue this command to see available options for CMC
Ubuntu: ./chainweb-mining-client -h
Windows: chainweb-mining-client.exe -h
For your mining client to work, it needs to connect to a node. You will need to provide a node that you have authorization to mine on.
--node 10.10.100.10:1848 or --node --node domainName:1848
Port 1848 is hardcoded and can’t be changed; that’s Kadena node service API port.
Difficulty for under 100 combined terahash should be in the range of 45 to 50. If you don’t want to submit shares as often, then you can increase the difficulty or just use block instead. Using block means you’ll only send shares that solve a block to CMC — not advisable unless you have massive amount of hash power.
Thread count should be what you think it should be. If you’re connecting under 50 machines, I think 1 thread per 10 KD Boxes is good. If not, experiment.
Stratum port is whatever port you want to use. Just make sure you’re not using a port already in use. If that’s the case, the program will tell you – read error messages.
Kadena Solo Mining Collective
This is a collective I started to allow solo miners come together to mine as group. There will be regional hosts for different parts of the world for better latency. Additionally, this is FREE. I will have volunteers who will provide servers that will be mined on. Having a collective of solo miners helps decentralize the Kadena network.
Poolflare is the best pool, hands down. Nothing compares. I still have some of my miners on there but still solo mining at the same time. Since Poolflare controls almost 80% of the network hashrate, it makes sense to spread the hashrate around. Joining this collective might help so that we earn similar, if not more than we would earn mining on Poolflare. If Poolflare had 40% of the hashrate, that won’t be an issue, but they have most of the network hashrate.
Happy Mining!
Click here to visit the Official mining client repository.
=== Plugin Name ===
Contributors: kubi23
Tested up to: 5.9
Stable tag: 5.4.14
Requires at least: 3.0
Tags: wordpress, plugin, mail, e-mail, notification, update, updates, notifications, mail-on-update, email, plugins, inform, version, versions
Sends an e-Mail to one or multiple administrators if new updates of plugins are available.
== Description ==
Since WordPress Version 2.5, WordPress automatically checks if a new update for an installed plugin is available. However, you still have to check your wp-admin to see the notification. This plugin informs you via e-Mail when a new update is available.
It uses the WordPress build-in update function to periodically check for new versions at the WordPress plugin directory. If a new version is available, either a single or multiple administrators will recieve an e-mail, informing them which plugins needs to be updated.
= Available Languages =
* German
* English
* Russian
== Installation ==
1. Download Plugin an unzip
2. Copy complete folder to your WordPress plugin-folder
3. Activate plugin via wp-admin
4. Go to Settings -> Mail On Update and set your options (if required)
Done.
== Changelog ==
= 5.4.14 =
* Clean and set copyright to 2022
= 5.4.13 =
* Cosmetics on settings
= 5.4.12 =
* Updated versions
= 5.4.11 =
* Changed target URL of plugin updates
= 5.4.10 =
* Fixed bug where no emails where send out
= 5.4.9 =
* Updated email sender header
= 5.4.8 =
* Very minor cleanup
= 5.4.7 =
* Very minor cleanup
* Refactored debugging information
= 5.4.6 =
* Fixed potential double sending of emails
= 5.4.5 =
* Added update call to wp_header as well as wp_footer
* Added Debug option
= 5.4.4 =
* Fixed bug that overwrite recipients when saving filters
= 5.4.3 =
* Fixed typo
* Updated WordPress compatibility
* Removed flattr links
= 5.4.2 =
* Translation fix
= 5.4.1 =
* Fixed deprecated PHP 7 warning
= 5.4.0 =
* Added new WordPress translation feature
* Tested with latest WordPress version 4.4.5
= 5.3.5 =
* Fixed wrong URL in eMail Template when WordPress is installed in subdirectory
* Fixed PHP warning when saving recipients
* Fixed various PHP warnings and notices
* Tested with latest WordPress version 4.3.0
= 5.3.4 =
* Fixed typo in german translation
= 5.3.3 =
* Fixed some PHP notices
= 5.3.2 =
* Fixed typo in german translation
* Updated mail footer
= 5.3.1 =
* Replaced JQuery with compliant WordPress version
* (Re-)Added russian translation (Thanks to Flector)
= 5.3.0 =
* Added option to select multiple admin recipients
* Remove Flattr button from backend and moved it to email footer
* Fixed bug that reseted the settings when plugin was deactivated
* Added nonce check to form
* Removed unmanged translations
* Updated translations
* Minor code cleanup
= 5.2.6 =
* Tested and released agains WP 4.1
= 5.2.5 =
* Removed deprecated function call (Thanks to Patabugen)
= 5.2.4 =
* Re-added flattr button
* Minor code cleanup
* Added licence tag
= 5.2.3 =
* Replaced deprecated PHP function split (Thanks to Simon Hampel)
= 5.2.2 =
* Removed Flattr Link
= 5.2.1 =
* Fixed typos
= 5.2.0 =
* Fixed slightly possible CSRF security vulnerability (CVE-2013-2107)
= 5.1.0 =
* Reverted to version 4.6.0 as 5.0.0 needs more testing
= 5.0.0 =
* Plugin now requires WordPress 3.0 +
* Plugin now checks for theme and WordPress Core updates
* Updated functions for PHP > 5.3 compatibility
* Notification is only send to users with update permission
* First update call is initiated after activation, not 12 hours
* Updated translations
* GREAT THANKS TO HEIKO ADAMS!!!
= 4.6.0 =
* Minor Code clean up
* Check compatability with WordPress 3.5
= 4.5 =
* Fixed some deprecated message
= 4.4 =
* Minor code cleanup
* Added Donation Link in readme
= 4.3 =
* Added Option to inform only once per Update (thanks to Sander, vandragt.com)
= 4.2 =
* Added Flattr button
= 4.1 =
* Fixed Bug with WordPress 3.0
* Plugin requires now at least WordPress 2.8
* Updated language files
= 4.0 =
* Added compatibility to WordPress 3.0
* Updated language files
= 3.4 =
* Code-Cleanup
* Update language files
= 3.3 =
* Removed debug informations which made it in the release (sorry)
* Change Subject of notifcation E-Mails
* Added new WordPress Plugins Changelog
= 3.2 =
* WordPress-Plugin SVN Error, which did not allow 3.2 commit?!
= 3.1 =
* Fixed incompatibility with WordPress 2.8
= 3.0 =
* Changed handling of options
* Code cleanup and improvements
* New style for settings page
* Update language file
= 2.7 =
* Added current and new version to notification mail
* Update language file
= 2.6 =
* Fixed Bug when using filter
* Added French translation
= 2.5 =
* Fixed Bug with umlaut
* Fixed Bug when checke WordPress Version
= 2.4 =
* Fixed Bug when validating E-Mail-Adresses
* Fixed Bug with UTF-8 encoding
* Fixed Bug when validating if a plugin is active or not
* Updated language file
= 2.3 =
* Fixed Bug when sending notifications
= 2.2 =
* Fixed Pharse Error
= 2.1 =
* Updated language file
= 2.0 =
* Added Option page
* Added Option for alternative Recipients
* Added Option to filter Plugins
* Added Option to not inform user if a plugin is anctive
* Update language file
* Update readme file
= 1.5 =
* Changed E-Mail Notification
= 1.4 =
* Minor code cleanup
= 1.3 =
* Fixed bug in E-Mail Notification
= 1.2 =
* Stable Release
* Minor code cleanup
= 1.1 Beta =
* Fixed: Blogname was missing
= 1.0 Beta =
* Initial version
If you want to contribute or build Scramle yourself, follow these steps to get going.
You need to have Git and Git LFS installed.
To start the project you need Godot 3.2.1.
# Get the source code and dependencies
$ git clone https://gitlab.com/ScrambleSim/Scramble.git
If you want to borrow assets directly from the protocol from your Ethereum wallet using JSON RPC and Web3.js, see the examples-js folder. There are examples for popular web3 libraries like Web3.js, Ethers.js, and Compound.js.
JSON RPC can be utilized in the web browser, with Node.js, or any other programming language with a web3 library.
If you want to borrow assets from the protocol from your Ethereum smart contract, see the examples-solidity folder.
What is Compound?
Compound is an open-source, autonomous protocol built for developers, to unlock a universe of new financial applications. Interest and borrowing, for the open financial system. Learn more on the website:
Setup
The code in this repository can be used to borrow assets from Compound on the Ethereum mainnet, any public test net, or your own localhost with Hardhat.
If you haven’t already, install Node.js LTS. Clone this repository, cd to the root directory of the project, and run:
git clone git@github.com:compound-developers/compound-borrow-examples.git
cd compound-borrow-examples/
npm install
We’ll need npx for this project. If you don’t have npx, install it using this command:
npm install -g npx
If you want to use the JS examples in the web browser, you’ll need to first import your web3 library of choice into your HTML (Web3.js, Ethers.js, or Compound.js). This step is not necessary if you are running the examples with only Node.js.
Running a Local Ethereum Testnet with Hardhat
To get the localhost testnet running, use the following commands in a second command line window. The command runs a local Hardhat node and forks Ethereum Mainnet to your machine.
cd compound-supply-examples/
## Set environment variables for the script to useexport MAINNET_PROVIDER_URL="https://mainnet.infura.io/v3/<YOUR INFURA API KEY HERE>"export DEV_ETH_MNEMONIC="clutch captain shoe salt awake harvest setup primary inmate ugly among become"## Runs the Hardhat node locally## Also seeds your first mnemonic account with test Ether and ERC20s
node ./scripts/run-localhost-fork.js
Borrowing Assets Directly via Web3 JSON RPC
These code examples can be run by a web browser or with Node.js. If you want to use a web browser, you’ll need to import a library in your HTML or JS file.
Running these scripts will give your wallet borrowed ETH and Dai. cTokens are ERC20 Tokens that can be used to redeem an ever-increasing amount of the underlying asset. The cToken exchange rate increases every Ethereum block, they can be transferred, and can be used to redeem at any time, as long as the underlying collateral does not support an open borrow.
Localhost Test Net
Run your local testnet in a second command line window using the command above. This will seed your account with ERC20 tokens. Look at the script file to find other ERC20 tokens that can be seeded into the account.
node examples-js/web3-js/borrow-erc20-with-eth-collateral.js To borrow Dai with ETH collateral.
node examples-js/web3-js/borrow-eth-with-erc20-collateral.js To borrow ETH with Dai collateral.
Check out the other examples for Ethers.js and Compound.js in the examples-js folder; They all do the same thing.
Public Test Net or Main Net
Make sure you have a wallet with ETH for the Ethereum network you plan to interface with (Main, Ropsten, Kovan, etc.).
Insert the private key of your wallet in the scripts where noted. It’s a best practice to insert the private key using an environment variable instead of revealing it in the code with a string literal.
Replace the HTTP provider in the web3 constructors in the JS scripts in web3-js-examples/. Replace it using the string provided by the “Endpoint” selector in your Infura project dashboard. The localhost test net provider is http://127.0.0.1:8545.
Next, replace the contract addresses in the JSON file with the most recent ones. You can find Compound’s cToken contract addresses for each network on this page: https://compound.finance/docs#networks.
Borrowing Assets With a Solidity Smart Contract
The examples send ETH or DAI to a smart contract, which then mints cETH or cDAI. The contract also marks the assets as collateral for borrowing. Next other assets can be borrowed from the protocol.
Localhost Testnet
Run your local testnet in a second command line window using the command above. This will seed your account with ERC20 tokens. Look at the script file to find other ERC20 tokens that can be seeded into the account.
Compile the smart contract in ./contracts/ by running npx hardhat compile
Next, deploy the smart contract to the localhost blockchain. npx hardhat run ./scripts/deploy.js --network localhost
Now that the contract is deployed, copy the address that is logged by the deploy script and paste it into the example script, so it knows where to direct its transactions. All JS files in the examples-solidity directory have a variable called myContractAddress which is where the MyContract address should be supplanted.
Now you can run any of the following examples to supply via smart contract.
node ./examples-solidity/web3-js/borrow-erc20-via-solidity.js To supply ETH as collateral and borrow Dai.
node ./examples-solidity/web3-js/borrow-eth-via-solidity.js To supply Dai as collateral and borrow ETH.
node examples-js/web3-js/borrow-erc20-with-eth-collateral.js
My Wallet's ETH Balance: 10000
My Wallet's cETH Balance: 0
My Wallet's DAI Balance: 100
Supplying ETH to the protocol as collateral (you will get cETH in return)...
My Wallet's ETH Balance: 9998.999600295
My Wallet's cETH Balance: 49.86112032
My Wallet's DAI Balance: 100
Entering market (via Comptroller contract) for ETH (as collateral)...
Calculating your liquid assets in the protocol...
Fetching cETH collateral factor...
Fetching DAI price from the price feed...
Fetching borrow rate per block for DAI borrowing...
You have 3384.441740171433 of LIQUID assets (worth of USD) pooled in the protocol.
You can borrow up to 75% of your TOTAL collateral supplied to the protocol as DAI.
1 DAI == 1.000000 USD
You can borrow up to 3384.441740171433 DAI from the protocol.
NEVER borrow near the maximum amount because your account will be instantly liquidated.
Your borrowed amount INCREASES (2.2076358156e-8 * borrowed amount) DAI per block.
This is based on the current borrow rate.
Now attempting to borrow 50 DAI...
My Wallet's ETH Balance: 9998.998558725
My Wallet's cETH Balance: 49.86112032
My Wallet's DAI Balance: 150
Fetching DAI borrow balance from cDAI contract...
Borrow balance is 50 DAI
This part is when you do something with those borrowed assets!
Now repaying the borrow...
Approving DAI to be transferred from your wallet to the cDAI contract...
Borrow repaid.
My Wallet's ETH Balance: 9998.99801022
My Wallet's cETH Balance: 49.86112032
My Wallet's DAI Balance: 100
Borrow ETH via Web3 JavaScript
Output Example
node examples-js/web3-js/borrow-eth-with-erc20-collateral.js
My Wallet's ETH Balance: 10000
My Wallet's cDAI Balance: 0
My Wallet's DAI Balance: 100
Approving DAI to be transferred from your wallet to the cDAI contract...
Supplying DAI to the protocol as collateral (you will get cDAI in return)...
My Wallet's ETH Balance: 9999.99525988
My Wallet's cDAI Balance: 691.40915384
My Wallet's DAI Balance: 85
Entering market (via Comptroller contract) for ETH (as collateral)...
Calculating your liquid assets in the protocol...
Fetching the protocol's DAI collateral factor...
Fetching DAI price from the price feed...
Fetching borrow rate per block for ETH borrowing...
You have 11.249999999912092756 of LIQUID assets (worth of USD) pooled in the protocol.
You can borrow up to 75% of your TOTAL assets supplied to the protocol as ETH.
1 DAI == 1.000000 USD
You can borrow up to 11.249999999912092756 USD worth of assets from the protocol.
NEVER borrow near the maximum amount because your account will be instantly liquidated.
Your borrowed amount INCREASES (1.1208317598e-8 * borrowed amount) ETH per block.
This is based on the current borrow rate.
Now attempting to borrow 0.002 ETH...
ETH borrow successful.
My Wallet's ETH Balance: 9999.98912288
My Wallet's cDAI Balance: 691.40915384
My Wallet's DAI Balance: 85
Fetching your ETH borrow balance from cETH contract...
Borrow balance is 0.002 ETH
This part is when you do something with those borrowed assets!
Now repaying the borrow...
Borrow repaid.
My Wallet's ETH Balance: 9999.98426352
My Wallet's cDAI Balance: 691.40915384
My Wallet's DAI Balance: 85
Borrow ERC20 via Solidity
Output Example
node examples-solidity/web3-js/borrow-erc20-via-solidity.js
My Wallet's ETH Balance: 10000
MyContract's ETH Balance: 0
MyContract's cETH Balance: 0
MyContract's DAI Balance: 0
Calling MyContract.borrowErc20Example with 1 ETH for collateral...
My Wallet's ETH Balance: 9998.98883272
MyContract's ETH Balance: 0
MyContract's cETH Balance: 49.86111985
MyContract's DAI Balance: 10
Now repaying the borrow...
My Wallet's ETH Balance: 9998.9852758
MyContract's ETH Balance: 0
MyContract's cETH Balance: 49.86111985
MyContract's DAI Balance: 0
Borrow ETH Token via Solidity
Output Example
node examples-solidity/web3-js/borrow-eth-via-solidity.js
My Wallet's DAI Balance: 100
MyContract's ETH Balance: 0
MyContract's cETH Balance: 0
MyContract's DAI Balance: 0
MyContract's cDAI Balance: 0
Sending 25 DAI to MyContract so it can provide collateral...
My Wallet's DAI Balance: 75
MyContract's ETH Balance: 0
MyContract's cETH Balance: 0
MyContract's DAI Balance: 25
MyContract's cDAI Balance: 0
Calling MyContract.borrowEthExample with 25 DAI as collateral...
My Wallet's DAI Balance: 75
MyContract's ETH Balance: 0.002
MyContract's cETH Balance: 0
MyContract's DAI Balance: 0
MyContract's cDAI Balance: 1152.34787526
Now repaying the borrow...
My Wallet's DAI Balance: 75
MyContract's ETH Balance: 0
MyContract's cETH Balance: 0
MyContract's DAI Balance: 0
MyContract's cDAI Balance: 1152.34787526
Minting Localhost Test ERC20s
All assets supported by the Compound protocol can be seeded into the first account when doing localhost testing. See the amounts object at the top of the script ./scripts/run-localhost-fork.js. You can add assets and amounts to this object. When the localhost fork script is run, Hardhat will move tokens from a whale (cToken contract) to the first wallet of your selected mnemonic (in your environment variable). You can then use these assets freely on your localhost fork.
Ethers.js & Compound.js Examples
There are several other code examples for ethers.js and Compound.js. These SDKs can be used instead of Web3.js in each instance. Each version of the script does the same operations. To try the other code examples, run the scripts in the other folders.