(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4634],{66957:function(n,e,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/product/foundation/v2",function(){return t(49445)}])},49445:function(n,e,t){"use strict";t.r(e),t.d(e,{default:function(){return p}});var o=t(828),i=t(85893),a=t(67294),s=t(10272),r=t(10165),c=t(84880),l=t(13520),u=t(50657),d=t(39944),h=t(99339),f=t(73897),g=t(54045),m=t(9003);function p(n){var e=n.theme,t=n.toggleTheme,p=(0,o.Z)((0,a.useState)(""),2),b=p[0],v=p[1],y=(0,o.Z)((0,a.useState)(""),2),w=y[0],k=y[1],x=(0,o.Z)((0,a.useState)(!0),2),C=x[0],T=x[1],F=(0,o.Z)((0,a.useState)(null),2),S=F[0],P=F[1],j=(0,a.useMemo)(function(){return["The user is not authenticated","No current user"]},[]),z=(0,a.useCallback)(function(n){console.error(n),v(c.I),k(s.xe.ERROR)},[]);return((0,a.useEffect)(function(){C&&(parseFloat("0")?T(!1):f.hm().then(function(n){T(!1),P(n)}).catch(function(n){T(!1),j.includes(n)||z(n)}))},[j,C,z]),C)?(0,i.jsx)(g.mn,{children:(0,i.jsx)(r.T,{style:{width:"120px",height:"120px"}})}):(0,i.jsxs)(a.Fragment,{children:[(0,i.jsx)(g.xB,{}),(0,i.jsx)(l.Z,{alert:b,alertType:w,clear:function(){v(""),k("")}}),(0,i.jsx)(d.Z,{theme:e,user:S,toggleTheme:t,updateAlertMain:v,updateAlertMainType:k}),(0,i.jsx)(h.Z,{component:"/product/foundation/v2",headers:m.PM,pages:["/product/foundation/v2/overview","/product/foundation/v2/configuration","/product/foundation/v2/endpoints"],resources:m._B,sections:m.bx,title:"Foundation Core (v2)",theme:e,versions:m.Lh}),(0,i.jsx)(u.Z,{})]})}},9003:function(n,e,t){"use strict";t.d(e,{Lh:function(){return s},PM:function(){return r},_B:function(){return a},bx:function(){return i}});var o=t(28208),i=[{Introduction:"\nFoundation (v2) was born out of a desire to simplify the process of creating, hosting,\nand managing a mining pool for the layman. It's no secret that mining pools, and\nthe mining process as a whole, have been becoming more and more centralized, especially\nfor smaller altcoins, where a single pool is most often responsible for the majority\nof the hashrate on the network. Viable, easy-to-use, open-source software would not only\nhelp to solve this issue, but it would provide another way for many less-technical\nindividuals to supplement their income passively while contributing to a project. Anyone\nshould be able to setup and host a mining pool with minimal difficulties.\n\nThis documentation will outline each of the individual modules that make up Foundation (v2),\nas well as a breakdown of the API and configuration files, tutorials that explain how to\nsetup and work with Foundation (v2), and a repository of FAQs. If you need help with any code-related\nmatters, the first place to look is our [Discord](https://discord.gg/rNjez6VgNF), where\nthe developers will be available to answer any questions. However, please try not to come\nwith issues regarding setup. Use Google and the existing documentation for that.\n","Why Foundation (v2)?":"\nFoundation (v2) comes as the result of a complete rewrite of the Foundation (v1) protocol.\nWhile its predecessor mainly was an attempt to expand and build out the NOMP framework\nestablished by Matthew Little, Foundation (v2) was built from scratch in an attempt to\ntruly redefine the standard of open-source mining pool software. The entire system and\narchitecture was redesigned to promote scalability and to do away with some of the design\ndecisions that were causing issues in Foundation (v1). Some of the main improvements\ninclude the following:\n\n* PostgreSQL integration\n* ACID transactions to ensure database stability\n* Batch share processing and recovery options for network outages\n* Full support for multi-threading and multiple stratum servers\n* Full support for historical data storage and complex queries\n* Reorganized configurations that are more intuitive/cleaner\n* Reorganized database schema that is more intuitive/cleaner\n* Individual coin templates to simplify code and development\n* Reorganized/reworked API to improve performance and usability\n\nAs mentioned, the most important change of Foundation (v2) from Foundation (v1) and NOMP\nis the decision to switch from Redis to a PostgreSQL database. Not only does this allow\nfor greater performance and flexibility, it also permits the storage and usage of historical\ndata, as the pool itself no longer stores data in memory.\n"},{Modules:"\nUnlike its predecessor, Foundation (v2) only consists of two modules. The first module is\nthe server itself ([foundation-server](https://github.com/blinkhash/foundation-v2-server)),\nwhich is responsible for all the functionality relating to the pool. It handles all\ncommunication that involves the backend database and API, including share processing,\nuser queries, statistics management, worker handling, and sending out payments. The second\nis the individual coin templates that interface with the server\n([foundation-template](https://github.com/blinkhash/foundation-v2-template)). They're\nresponsible mainly for facilitating communication with the coin's daemon, and work\nwith connected miners to verify the quality of work being submitted. Overall, though,\neach module has a role to play in the mining process and fulfills it accordingly. This\nsection will help to further examine each module and what it has to offer.\n","Foundation-Server":"\nFoundation's (v2) server is the main module that controls the mining pool and related\nfunctionality. As mentioned, it's responsible for all communication involving the backend\ndatabase and API. Whenever a share is submitted to the pool or an API request is made,\nit handles everything to ensure that the proper queries execute or information is returned.\nIt also handles three individual processes that run at regular intervals: 'checks',\n'payments', and 'statistics'. By default, 'checks' and 'statistics' run every ninety seconds.\nThe former handles everything with pending/confirmed blocks and keeps a record of coins owed\nto miners, while the latter ensures that all round and miner statistics are kept up-to-date\nand consistent. The 'payments' process runs by default every two hours, and sends out\npayments for any confirmed blocks.\n","Foundation-Templates":"\nFoundation's (v2) coin templates are a collection of stratum services built specifically\nto support individual coins. They interface directly with the Foundation (v2) server as\nNode.JS packages and handle all communication with the coin's daemon. Whenever a miner\nconnects to an active pool and starts to submit shares, the template is responsible for\ndouble-checking the miner's work and determining whether any submissions are block candidates.\nWhen prompted, it also handles sending out payments to miners and will notify the server\nwhen any notable events occur. The currently supported templates include the following:\n\n~~~txt\nBitcoin - https://github.com/blinkhash/foundation-v2-bitcoin\nDash - https://github.com/blinkhash/foundation-v2-dash\nDogecoin - https://github.com/blinkhash/foundation-v2-dogecoin\nEvrmore - https://github.com/blinkhash/foundation-v2-evrmore\nFirocoin - https://github.com/blinkhash/foundation-v2-firocoin\nGarlicoin - https://github.com/blinkhash/foundation-v2-garlicoin\nLitecoin - https://github.com/blinkhash/foundation-v2-litecoin\nPeercoin - https://github.com/blinkhash/foundation-v2-peercoin\nRaptoreum - https://github.com/blinkhash/foundation-v2-raptoreum\nRavencoin - https://github.com/blinkhash/foundation-v2-ravencoin\nVertcoin - https://github.com/blinkhash/foundation-v2-vertcoin\nZCash - https://github.com/blinkhash/foundation-v2-zcash\n~~~\n\nAs mentioned, each of these templates were built out to support a single, specific coin.\nWhile they may be able to be repurposed for identical clones of the coin, always make sure\nto confirm their functionality on a testnet before deploying in production.\n"},{"Getting Started":"\nThis section will offer a tutorial on how to setup Foundation (v2) to mine Bitcoin on your\nlocal machine. This process can be extrapolated to any other coin that uses one of\nthe supported templates. See the 'Configuration' page for an in-depth explanation of the\nconfiguration files used in this tutorial.\n",Requirements:"\nTo start off, you'll need to install the following:\n\n* NodeJS v10.0+\n* PostgreSQL Database v12+\n\nIn our development environment, Foundation (v2) is currently being built with NodeJS v12.16,\nPostgreSQL Database v14.4, and Ubuntu 20.04. Each build has been tested with NodeJS v11.x-v15.x, and\nas such most versions of NodeJS should be fine to use. If you find yourself experiencing any\nerrors or difficulties with NodeJS, try and upgrade/downgrade to v12.16 and see if that solves\nyour issues.\n\n~~~bash\nsudo apt-get update\ncurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash\nsource ~/.profile\nnvm install 12.16.1\nsudo apt install postgresql postgresql-contrib\nsudo systemctl start postgresql.service\n~~~\n","Setting up PostgreSQL":"\nBy default, once PostgreSQL is installed, a standard user account called 'postgres' will\nbe created. You'll most likely want to create a new user account specifically for\nFoundation (v2). To do so, running the following command:\n\n~~~bash\nsudo -u postgres createuser -P -s -e --interactive\n~~~\n\nOnce entered, you'll see the following prompt. Enter the name and password of the user\nthat you want to create.\n\n~~~txt\nEnter name of role to add: blinkhash\nEnter password for new role:\nEnter it again:\n~~~\n\nFinally, you'll need to create a database for Foundation (v2) to leverage.\n\n~~~bash\nsudo -u postgres createdb foundation\n~~~\n","Setting up Daemon":"\nFor the coin daemon, you'll want to refer to the specific build instructions given out\nby the developers of the coin. For Bitcoin, you can find the binaries\n[here](https://bitcoin.org/en/download). Make sure that you're downloading the most recent\nbuild to ensure the safety and stability of your mining pool.\n\n~~~bash\nwget https://bitcoin.org/bin/bitcoin-core-22.0/bitcoin-22.0-x86_64-linux-gnu.tar.gz\ntar -xzvf bitcoin-22.0-x86_64-linux-gnu.tar.gz\n~~~\n\nOnce the daemon has been downloaded, you'll want to setup your configuration file. Refer\nto your specific coin's documentation when necessary.\n\n~~~bash\nmkdir ~/.bitcoin\nnano ~/.bitcoin/bitcoin.conf\n~~~\n\n~~~txt\nrpcuser=blinkhash\nrpcpassword=password\nrpcallowip=0.0.0.0/0\nserver=1\nlisten=1\ndaemon=1\nprune=10000\n~~~\n\n~~~bash\n~/bitcoin-22.0/bin/bitcoind --daemon\n~~~\n\nYou'll also want to generate a wallet address using the daemon at this point, as you'll\nneed it to indicate which address to send funds to when you're configuring the pool in\na few steps.\n\n~~~bash\n~/bitcoin-22.0/bin/bitcoin-cli createwallet \"testwallet\"\n~/bitcoin-22.0/bin/bitcoin-cli getnewaddress\n# Ex: bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq\n~~~\n\nAt this point, your daemon should start the process of downloading the blockchain. The\namount of time that this will take is variable, and depends on how many blocks have\nbeen added to your coin's blockchain. For Bitcoin, it should take a few hours (~6) to\nsync with the network. If you want, you can continue with this tutorial while your\ndaemon is syncing, but the pool server will not be able to start until it's finished.\n\nFor redundancy, its recommended to have at least two daemon instances running in case\none drops out-of-sync or your server crashes, as all instances will be polled for\nblock/transaction updates and can be used for submitting blocks.\n","Downloading & Installing":"\nAfter configuring the daemon, the next step is to go about downloading and installing\ndependencies for the Foundation (v2) server itself. Make sure to use the latest release rather\nthan cloning the repository itself.\n\n~~~bash\nsudo apt-get install build-essential libsodium-dev libboost-system-dev\ngit clone https://github.com/blinkhash/foundation-v2-server.git foundation-server\ncd foundation-server && npm install\n~~~\n","Configuring Server":"\nTo configure the server, first rename the 'configs/main/example.js' file to\n'configs/main/config.js' and make any desired changes. See the 'Configuration' page\nfor a breakdown and explanation of each property mentioned in the file. The default\nconfiguration will also most likely work for your environment. Make sure to fill in\nthe SQL configuration with the username, password, and database that you generated\npreviously in 'Setting up PostgreSQL'.\n\n~~~bash\ncp configs/main/example.js configs/main/config.js\nnano configs/main/config.js\n~~~\n\n~~~js\n// Miscellaneous Configuration\nconst config = {};\nconfig.identifier = '';\nconfig.language = 'english';\n\n// Logger Configuration\nconfig.logger = {};\nconfig.logger.logColors = true;\nconfig.logger.logLevel = 'log';\n\n// Database Configuration (SQL)\nconfig.client = {};\nconfig.client.tls = false;\n\n// Master Database\nconfig.client.master = {};\nconfig.client.master.host = '127.0.0.1';\nconfig.client.master.port = 5432;\nconfig.client.master.username = 'blinkhash';\nconfig.client.master.password = 'password';\nconfig.client.master.database = 'foundation';\n\n// Worker Database\nconfig.client.worker = {};\nconfig.client.worker.host = '127.0.0.1';\nconfig.client.worker.port = 5432;\nconfig.client.worker.username = 'blinkhash';\nconfig.client.worker.password = 'password';\nconfig.client.worker.database = 'foundation';\n\n// Clustering Configuration\nconfig.clustering = {};\nconfig.clustering.enabled = true;\nconfig.clustering.forks = 'auto';\n\n// TLS Configuration\nconfig.tls = {};\nconfig.tls.ca = '';\nconfig.tls.key = '';\nconfig.tls.cert = '';\n\n// Server Configuration\nconfig.server = {};\nconfig.server.host = '127.0.0.1';\nconfig.server.port = 3001;\nconfig.server.tls = false;\n\n// Cache Configuration\nconfig.server.cache = {};\nconfig.server.cache.enabled = true;\nconfig.server.cache.timing = '1 minute';\n\n// Limiter Configuration\nconfig.server.limiter = {};\nconfig.server.limiter.enabled = true;\nconfig.server.limiter.window = 900000; // ms\nconfig.server.limiter.maximum = 100;\n\n// Export Configuration\nmodule.exports = config;\n~~~\n","Adding Templates":"\nBefore you can start building out mining pools, you'll need to install the correct\ntemplates so that Foundation (v2)'s server can leverage them. These templates are able to\nbe installed as Node.JS packages through NPM. The following command demonstrates how to\ninstall the 'foundation-v2-bitcoin' package:\n\n~~~bash\nnpm install --save foundation-v2-bitcoin\n~~~\n","Configuring Templates":"\nTo configure the template itself, copy the 'configs/pools/example.js' file to a separate\none and rename it accordingly before making any desired changes. Unlike the server\nconfiguration, the default settings will most likely not work for your template. See the\n'Configuration' page for a breakdown and explanation of each property mentioned in\nthe file, or check [here](https://github.com/blinkhash/foundation-v2-configurations) for a\nlist of configuration files that have been confirmed to work properly.\n\n~~~bash\ncp configs/pools/example.js configs/pools/bitcoin.js\nnano configs/pools/bitcoin.js\n~~~\n\n~~~js\n// Miscellaneous Configuration\nconst config = {};\nconfig.enabled = true;\nconfig.name = 'Pool-Bitcoin';\nconfig.template = 'bitcoin';\n\n// Miscellaneous Configuration\nconfig.primary = {};\nconfig.primary.address = 'bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq';\n\n// Coin Configuration\nconfig.primary.coin = {};\nconfig.primary.coin.name = 'Bitcoin';\nconfig.primary.coin.symbol = 'BTC';\nconfig.primary.coin.algorithm = 'sha256d';\n\n// Checks Configuration\nconfig.primary.checks = {};\nconfig.primary.checks.enabled = true;\n\n// Daemon Configuration\nconfig.primary.daemons = [];\n\nconst daemons1 = {};\ndaemons1.host = '127.0.0.1';\ndaemons1.port = 8332;\ndaemons1.username = 'blinkhash';\ndaemons1.password = 'password';\nconfig.primary.daemons.push(daemons1);\n\n// Payment Configuration\nconfig.primary.payments = {};\nconfig.primary.payments.enabled = true;\nconfig.primary.payments.minConfirmations = 10;\nconfig.primary.payments.minPayment = 0.005;\nconfig.primary.payments.transactionFee = 0.004;\nconfig.primary.payments.daemon = {};\nconfig.primary.payments.daemon.host = '127.0.0.1';\nconfig.primary.payments.daemon.port = 8332;\nconfig.primary.payments.daemon.username = 'blinkhash';\nconfig.primary.payments.daemon.password = 'password';\n\n// Recipients Configuration\nconfig.primary.recipients = [];\n\nconst recipient1 = {};\nrecipient1.address = 'bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq';\nrecipient1.percentage = 0.05;\nconfig.primary.recipients.push(recipient1);\n\n// Statistics Configuration\nconfig.primary.statistics = {};\nconfig.primary.statistics.enabled = true;\n\n// ZMQ Configuration\nconfig.primary.zmq = {};\nconfig.primary.zmq.enabled = false;\nconfig.primary.zmq.host = '127.0.0.1';\nconfig.primary.zmq.port = 29000;\n\n// Port Configuration\nconfig.ports = [];\n\nconst ports1 = {};\nports1.port = 3002;\nports1.enabled = true;\nports1.type = 'shared';\nports1.tls = false;\nports1.difficulty = {};\nports1.difficulty.initial = 524288;\nports1.difficulty.minimum = 262144;\nports1.difficulty.maximum = 1048576;\nports1.difficulty.targetTime = 15;\nports1.difficulty.retargetTime = 90;\nports1.difficulty.variance = 0.3;\nconfig.ports.push(ports1);\n\n// Settings Configuration\nconfig.settings = {};\n\n// Banning Configuration\nconfig.settings.banning = {};\nconfig.settings.banning.banLength = 600000; // ms;\nconfig.settings.banning.checkThreshold = 500;\nconfig.settings.banning.invalidPercent = 50;\nconfig.settings.banning.purgeInterval = 300000; // ms;\n\n// Batch Configuration\nconfig.settings.batch = {};\nconfig.settings.batch.limit = 200;\n\n// Timeout Configuration\nconfig.settings.timeout = {};\nconfig.settings.timeout.connection = 600000; // ms\nconfig.settings.timeout.rebroadcast = 60000; // ms\n\n// Interval Configuration\nconfig.settings.interval = {};\nconfig.settings.interval.blocks = 1000; // ms\nconfig.settings.interval.checks = 90000; // ms\nconfig.settings.interval.historical = 600000; // ms\nconfig.settings.interval.payments = 7200000; // ms\nconfig.settings.interval.recent = 600000; // ms\nconfig.settings.interval.rounds = 60000; // ms\nconfig.settings.interval.statistics = 90000; // ms\n\n// Window Configuration\nconfig.settings.window = {};\nconfig.settings.window.hashrate = 300000; // ms\nconfig.settings.window.inactive = 604800000; // ms\nconfig.settings.window.rounds = 21600000; // ms\nconfig.settings.window.updates = 300000; // ms\n\n// Export Configuration\nmodule.exports = config;\n~~~\n","Starting Pool Service":"\nOnce everything has been configured, you can now go and start your server process. If your\ndaemon has not yet finished downloading the blockchain, you will see a message stating that\nthe 'Daemon is still syncing with the network. The server will be started once synced'. It\nwill also give periodic updates on the current syncing progress.\n\n~~~bash\nnpm run start\n~~~\n"}],a=[{Modules:"","foundation-v2-server":"https://github.com/blinkhash/foundation-v2-server","foundation-v2-configurations":"https://github.com/blinkhash/foundation-v2-configurations","foundation-v2-template":"https://github.com/blinkhash/foundation-v2-template"},{Templates:"","foundation-v2-bitcoin":"https://github.com/blinkhash/foundation-v2-bitcoin","foundation-v2-dash":"https://github.com/blinkhash/foundation-v2-dash","foundation-v2-dogecoin":"https://github.com/blinkhash/foundation-v2-dogecoin","foundation-v2-evrmore":"https://github.com/blinkhash/foundation-v2-evrmore","foundation-v2-firocoin":"https://github.com/blinkhash/foundation-v2-firocoin","foundation-v2-garlicoin":"https://github.com/blinkhash/foundation-v2-garlicoin","foundation-v2-litecoin":"https://github.com/blinkhash/foundation-v2-litecoin","foundation-v2-peercoin":"https://github.com/blinkhash/foundation-v2-peercoin","foundation-v2-raptoreum":"https://github.com/blinkhash/foundation-v2-raptoreum","foundation-v2-ravencoin":"https://github.com/blinkhash/foundation-v2-ravencoin","foundation-v2-vertcoin":"https://github.com/blinkhash/foundation-v2-vertcoin","foundation-v2-zcash":"https://github.com/blinkhash/foundation-v2-zcash"}],s={"Foundation v1":"/product/foundation/v1","Foundation v2":"/product/foundation/v2"},r=(0,o.xH)(i.map(function(n){return Object.keys(n)}))}},function(n){n.O(0,[4976,7948,825,496,1736,6906,9339,9774,2888,179],function(){return n(n.s=66957)}),_N_E=n.O()}]);