The core module of OIP written in Javascript!


An NPM module containing all of the core functionality to run any OIP front end.

Work in Progress

This section is a work in progress, so more information will be added periotically. Information may be out of data, for latest information, please read the code :)


There is a browserified version of OIP-JS that can be compiled with npm run browserify. You can find a demo of how to use the Browserified version inside of the /demofolder in this repository. Please note that the compiled bundle provided in the repo may not be the most up to date version. When in doubt, be sure to compile it using the command above for the latest version.


Inside of OIP-JS there are currently 11 modules. Each of the 11 modules have specific tasks to try and seperate the logic out. They are seperated as follows:

  • Artifact: This contains helper functions for manipulating artifact JSON.
  • Comments: This allows the user to simply comment on Artifacts
  • Data: This contains simple access to application information that was fetched by the network layer.
  • Index: This module provides access to OIPd and pulls data directly from an external OIPd server.
  • Network: Usually called by the Data layer. This module contains all of the server calls & network transfer functions (i.e. IPFS).
  • OIPd: Provides helper functions for pushing OIPd messages to the Florincoin Blockchain.
  • Publisher: Provides helper functions for publishers (i.e. registering a publisher, logging in, etc)
  • settings: A simple helper file that allows for easy setting of application settings. This contains most of the URL's to different external services.
  • User: Create, Sign-in, Pay, etc. This module provides User functions.
  • util: Other generally helpful utility functions that we have found helpful.
  • Wallet: This module provides access to OIPMWand also has a few wrapper functions. Allows users to Sign messages and send funds easily (along with Login, Logout, and Wallet creation)

Currently, we have implemented or planned the following functions:

** NOTE: As of 1/16/2018 this /should be/ a full list of all functions **


Core.Artifact.getTXID(oipArtifact): returns the txidof the given artifact.

Core.Artifact.getTitle(oipArtifact): returns the titleof the given artifact.

Core.Artifact.getType(oipArtifact): returns the typeof the given artifact.

Core.Artifact.getSubtype(oipArtifact): returns the subtypeof the given artifact.

Core.Artifact.getDescription(oipArtifact): returns the descriptionof the given artifact.

Core.Artifact.getFiles(oipArtifact): returns the data related to the files in the given artifact, Including dNames, fNames and playtimeand pricing fields. If any of the artifact is commercial, for all of the files which are available(free), returns ipfs file hashes as storage:files:location, and return"permission denied" for files which are not yet available (not yet paid for).

Core.Artifact.getLocation(oipArtifact): If the whole artifact is free, returns the location address of the given artifact (This is usually the IPFS hash, unless the Artifact uses another data storage layer) as storage:location. If any of the artifact is commercial, return"permission denied"

Core.Artifact.getPublisherName(oipArtifact): returns the Publisher Aliasfor the Publisherthat published the Artifact. If no Publisher Aliaswas specified, returns "Flotoshi"

Core.Artifact.getPublisher(oipArtifact): returns the Publisher Addresswhich published the artifact.

Core.Artifact.getArtist(oipArtifact): returns the Artistof the given artifact. If an Artistwas not specified, returns Publisher Aliasinstead.

Core.Artifact.getScale(oipArtifact): returns the int on the right side of the scale variable (i.e. "1:1000" would return 1000).

Core.Artifact.getMainFile(oipArtifact): returns first file that matches the Artifact "type" variable (i.e., if the type is Video, then we search for the first Videofile in the artifact).

Core.Artifact.getDuration(oipArtifact): returns the duration specified in the first file that has a duration on the Artifact.

Core.Artifact.getTipPrefs(oipArtifact): returns the suggested tip values.

Core.Artifact.getThumbnail(oipArtifact): returns the fNameof the Thumbnailfor the given artifact. This is calculated as the first File with the type "Image" that does not have a price to view it. Returns ""if no thumbnail can be found.

Core.Artifact.paid(oipArtifact): returns trueif any files have either a suggested buy price or suggested play price. Otherwise it will return false.

Core.Artifact.isFilePaid(oipFile): returns trueif the file has either a suggested buy price or suggested play price. Otherwise it will return false.

Core.Artifact.getPaymentAddresses(oipArtifact): returns a JSON object containing all supported payment method types and their associated coins.

Core.Artifact.getEntypoIconForType(oipArtifact): returns the css class for the artifact type. This will be removed/moved.


Core.Comments.get(artifactTxid, callback): provides via callbackthe comments on a specified Artifact.

Core.Comments.add(artifactTxid, comment, callback): adds a comment to an Artifact, then returns via callbackif successful.

Core.Comments.like(artifactTxid, callback): upvotes/likes a comment, calls callbackif successful.

Core.Comments.dislike(artifactTxid, callback): downvotes/dislikes a comment, calls callbackif successful.


Core.Data.getExchangeRate(coin, fiat, onSuccess({}), onError(error)): Returns the current per coin price for the requested coinand fiatpair. Calls the onSuccesscallback with the Fiat-Per-Coin rate (as a float).

Core.Data.getBTCPrice(onSuccess(USDPerBTC), onError(error)): Provides the USD to BTC price via the onSuccesscallback.

Core.Data.getFLOPrice(onSuccess(USDPerFLO), onError(error)): Provides the USD to FLO price via the onSuccesscallback.

Core.Data.getLTCPrice(onSuccess(USDPerLTC), onError(error)): Provides the USD to LTC price via the onSuccesscallback.

Core.Data.calculateBTCCost(usd_value, onSuccess(btc_amount), onError(error)): Provides the amount of BTC that the USD_value variable is worth via the onSuccesscallback.

Core.Data.getOIPdInfo(onSuccess, onError): Provides information about OIPd via the onSuccesscallback.


Core.Index.getSupportedArtifacts(callback(supportedArtifacts)): Provides an array of supported artifacts to the callback. All artifacts will be formatted based on the highest version supported by oip-js. Currently this is oip-041.

Core.Index.getRandomSuggested(onSuccess(suggestedArtifacts)): Provides a random array of 25 supported artifacts to the callback. All artifacts will be formatted based on the highest version supported by oip-js. Currently this is oip-041.

Core.Index.stripUnsupported(artifacts): returns an array of Artifacts minus those that are currently unsupported by the interface.

Core.Index.getArtifactFromID(id, callback(artifact)): Looks up an Artifact based on its id and returns it to the enduser via callback.

Core.Index.search(options, onSuccess, onError): Searches OIPd for artifacts using the options provided, returns found artifacts via the onSuccesscallback

Core.Index.getLatestArtifacts(callback(latestArtifacts)): This will grab the latest artifacts from OIPd and returnthem as a JSON array to the callback.

Core.Index.getRegisteredPublishers(onSuccess(registeredPublishers), onError(error)): Provides an array of registered publishers to the callback. All publishers will be formatted based on the highest version supported by oip-js, currently this is oip-041. paginated, sortable by various fields

Core.Index.getPublisher(oipPublisherAddress, onSuccess, onError): Provides Publisher Alias, BTC Address, TXID of registration message, registration timestamp, and email md5 hashfor given Publisher Address via the callback.

Core.Index.getPublisherArtifacts(oipPublisherAddress): returns a list of all artifactIDs by a given Publisher.


Core.Network.getLatestOIPdInfo(onSuccess, onError): Provides the latest information from the /infoOIPd api endpoint to the onSuccesscallback.

Core.Network.searchOIPd(options, onSuccess, onError): Searches OIPd for the options specified and returns the data to the onSuccesscallback.

Core.Network.getArtifactsFromOIPd(onSuccess, onError): Gets all the Artifacts currently in OIPd and returns the data to the onSuccesscallback.

Core.Network.getPublishersFromOIPd(onSuccess, onError): Gets all the Publishers currently in OIPD and returns the data to the onSuccesscallback.

Core.Network.getLatestBTCPrice(onSuccess, onError): Gets the latest BTC to USD price and returns the data to the onSuccesscallback.

Core.Network.getLatestFLOPrice(onSuccess, onError): Gets the latest FLO to USD price and returns the data to the onSuccesscallback.

Core.Network.getLatestLTCPrice(onSuccess, onError): Gets the latest LTC to USD price and returns the data to the onSuccesscallback.

Core.Network.getIPFS(callback): Passes the IPFS object to the callback after it has been successfully spawned. You are highly discouraged from using this function, but it is here for advanced functionality.

Core.Network.getThumbnailFromIPFS(hash, onDataCallback): Give it either an IPFS file hash or hash + subfile (i.e. hash/filename.png). Each time data is downloaded (i.e. on download progress), we call the onDataCallback and pass a base64 encoded version of the file. You can feed this directly into an image source and it will load fine :)

Core.Network.getFileFromIPFS(hash, onCompleteCallback): Give it either an IPFS file hash or hash + subfile (i.e. hash/filename.png). When the file download is complete, we call the onDataCallback and pass a base64 encoded version of the file. You can feed this directly into an image source and it will load fine :)

Core.Network.getCommentsFromISSO(uri, callback): Grabs the comments for the specified URI and returns them via callback

Core.Network.postCommentToISSO(uri, comment, callback): Add a comment to ISSO on the specified URI, calls the callbackon success.

Core.Network.likeISSOComment(id, callback): Likes an ISSO comment, calls the callbackon success.

Core.Network.dislikeISSOComment(id, callback): Dislikes an ISSO comment, calls the callbackon success.

Core.Network.tryOneTimeFaucet(address, recaptcha, onSuccess, onError): Try the One Time FLO faucet. If information is submitted correctly, it will provide tx info via the onSuccess callback.

Core.Network.tryDailyFaucet(address, recaptcha, onSuccess, onError): Try the Daily FLO faucet. If information is submitted correctly, it will provide tx info via the onSuccess callback.

Core.Network.tryFaucet(type, address, recaptcha, onSuccess, onError): Try the FLO faucet. If information is submitted correctly, it will provide tx info via the onSuccess callback. Type is either one_timeor intervalfor daily.

Core.Network.checkDailyFaucet(flo_address, onSuccess, onError): Check to see if you can receive funds via the Daily FLO Faucet, returns info to the onSuccess callback.


Core.OIPd.signPublisher(name, address, time): returns the requested signature.

Core.OIPd.signArtifact(ipfs, address, time): returns the requested signature.

Core.OIPd.signArtifactDeactivation(txid, publisher, timestamp):

Core.OIPd.signArtifactEdit(txid, timestamp): returns the requested signature.

Core.OIPd.signPublishArtifact(artifactJSON): returns the requested signature.

Core.OIPd.announcePublisher(name, address, email, onSuccess, onError): Announces a new Publisher to the network.

Core.OIPd.publishArtifact(artifactJSON, onSuccess, onError): Publishes an Artifact.

Core.OIPd.editArtifact(txid, newArtJSON, onSuccess, onError): Publishes an Artifact Edit.

Core.OIPd.deactivateArtifact(txid, onSuccess, onError): Publishes an Artifact Deactivation.

Core.OIPd.unixTime: returns the current Unix timestamp formatted to remove the miliseconds (since JS is in ms and the regular Unix timestamp is done in seconds).

Core.OIPd.send(jsonData, publishFee, onSuccess, onError): Publishes your requested jsonData with the specified publishFeeto the blockchain.

Core.OIPd.sendToBlockChain(txComment, publishFee, onSuccess, onError): Publishes your txComment to the FLO Blockchain. If more than one transaction is needed, it will automatically split up data using the Multipart protocol.

Core.OIPd.sendTX(txComment, publishFee, onSuccess, onError): Send a transaction with the specified txComment and publishFee.

Core.OIPd.multiPart(txComment, publishFee, onSuccess, onError): Sends out Multipart transactions containing the full txCommentrequested.

Core.OIPd.sendRestOfMultipart(multipartStrings, txidRef, addTxid, multipartDone, onError): Used internally to send the rest of the Multipart tx comments after the initial one is sent.

Core.OIPd.createMultipartStrings(longTxComment): Will provide you an array of strings that are the proper length to publish in Multipart messages.

Core.OIPd.createMultipartString(partNumber, maxParts, txidRef, stringPart): Creates a single mutlipart string to be published as a txComment.

Core.OIPd.chopString(input): Chops the inputted string into multipart compliant sizes and returns the array.

Core.OIPd.createSquashedPatch(original, modified): Create a Squashed JSON Edit Patch. returns the squashed patch.

Core.OIPd.squashPatch(patch): Squash a patch down to a more minimal state.

Core.OIPd.unSquashPatch(squashedPatch): Restore the patch to the full state.

Core.OIPd.calculatePublishFee(artJSON, onSuccess, onError): Calculates a publish fee for the supplied artJSON and returns a float via the onSuccesscallback.


Core.Publisher.Register(username, address, email, onSuccess, onError): Register the specified Username.


If you need to tweak any API endpoints, or the IPFS config, you can do so in the src/settings.jsfile.


Core.User.Register(email, password, onSuccess, onError): Register a new User.

Core.User.Login(identifier, password, onSuccess, onError): Login with your user to gain access to Wallet Functions.

Core.User.Logout: Logout your user.


Core.Wallet.on(eventType, runMeCallback): Subscribe to EventEmitter3 events emitted by the Wallet each time a transaction is sent. Currently, the only event type used is bal-update.

Core.Wallet.Create(email, password, onSuccess, onError): Create a wallet with the requested email password combo.

Core.Wallet.Login(identifier, password, onSuccess, onError): Login to a selected wallet.

Core.Wallet.Logout: Logout from your walelt.

Core.Wallet.getMainAddress(coin): returns the main address for the requested coin. Currently supported coins are bitcoin, florincoin, and litecoin.

Core.Wallet.checkDailyFaucet(flo_address, onSuccess, onError): Checks if you are able to use the daily faucet.

Core.Wallet.tryOneTimeFaucet(flo_address, recaptcha, onSuccess, onError): Attempts to receive funds from the one time faucet.

Core.Wallet.tryDailyFaucet(flo_address, recaptcha, onSuccess, onError): Attempts to receive funds from the daily faucet.

Core.Wallet.createAndEmitState(onSuccess, onError): Creates and emits a state via EventEmitter3 to anybody listening. This is currently emitted anytime balances are updated.

Core.Wallet.signMessage(address, message): returns the signature for the message & address requested.

Core.Wallet.refresh(onSuccess, onError): Refreshes the wallets information.

Core.Wallet.sendTxComment(options, onSuccess, onError): Directly send a transaction comment to the Blockchain.

Core.Wallet.sendPayment(coin, fiat, fiat_amount, payTo, onSuccess, onError): Send payment to a user. You can specify coins or usd for the fiatvariable.

Core.Wallet.createState: returns the current created Wallet State.

Core.Wallet.validateAddress(address, coin): Validates if the address is valid, returns true or false.


Core.util.chunksToFileURL(chunks, onLoad): This is used by the IPFS network layer to load byte arrays into a file URL reader, then return the fileURL base64 data to the onLoadcallback.

Core.util.buildIPFSShortURL(hash, filename): returns a built IPFS link to the IPFS resource. Use this if you don't want to download the file, but just get its hash reference.

Core.util.buildIPFSURL(hash, filename): returns a built HTTP link to the IPFS resource. Use this if you don't want to download the file, but just get the URL to access it.

Core.util.getExtension(filename): returns the file extension as a string. For example, pass this index.htmland it will return html.

Core.util.formatDuration(intDuration): returns a formatted duration in minutes and seconds (i.e. input 123 and get "2:03")

Core.util.decodeMakeJSONSafe(stringToDecode): This checks if there are non JSON supported characters that we should re-encode, if there are, then it encodes them and returns a fixed string, if not, it returns the original string.

Core.util.createPriceString(price): returns a price string that always has 3 digits.

Core.util.convertBTCtoBits(btc_value): returns the amount of bits in the btc_value requested.







  • 🙋Hanjst汉吉斯特改进+enSafeExpression安全表达式等

    Hanjst汉吉斯特模版语言及模版引擎,近期持续改进升级。 这次改进主要是增加了对安全输出表达式兼容,由于涉及到对软件开发过程中的效率和软件运行效率的平衡和取舍,所以多写了几句,以描述这个权衡利弊对...

    15 天前
  • 🙋Hanjst汉吉斯特升级:+showImageAsync及性能改进等

    自2019年元旦🙋Hanjst汉吉斯特 模板语言及其编译引擎发布,已经过去一年多了。 这期间随着 🙋Hanjst汉吉斯特 的推广应用,我们也陆续发布了如下一些更新内容: 🛠️Hanjst/汉吉...

    2 个月前
  • 😉我用 Nuxt.js 仿了个掘金

    前言 首先肯定是要夸夸掘金啦,最开始从 CSDN 到 博客园 再到 掘金,个人感觉掘金的技术氛围非常的nice,真是个宝藏社区👏。技术文章大多以前端为主,对前端开发者非常友好,质量也是歪瑞古的。

    25 天前
  • 😀一个原生js弹幕库

    danmujs 😀一个原生js弹幕库,基于 CSS3 Animation 地址、核心代码 本项目基于 rcbullets,项目约70%的代码基于rcbullets,首先要感谢这个项目的作者,如...

    4 个月前
  • 🕵️‍♀️由原型到JS中的“模拟类”

    讲述了有关 JavaScript 中原型相关知识,又引出了 JavaScript 中的“类“究竟是什么?,以及一系列相关问题。 一、前置知识 1、JavaScript 的面向对象(OOP) ​ 面向...

    2 个月前
  • 🔥《吊打面试官》系列 Node.js 必知必会必问!

    (/public/upload/f204a3b224d986128f1b4d9b8d06cd17) 前言 codeing 应当是一生的事业,而不仅仅是 30 岁的青春🍚 本文已收录 Git...

    3 个月前
  • 💖CSS + JS 送学妹满屏幕小爱心

    故事开始 午饭时间,暗恋已久的学妹拉着我的衣袖:“学长学长,你能不能让这些爱心变成五颜六色的吗~”。 我在旁边笑开了花~~~ image.png(/public/upload/04aaa24e...

    1 个月前
  • (vuejs学习)2、使用ElementUI(*)

    1.element安装 开发环境是win10,一到node官网下载node的.msi包(https://npm.taobao.org/mirrors/node/v10.16.0/nodev10.16....

    10 个月前
  • (vuejs学习)1、Vue初上手(*)

    参考《官方(https://cli.vuejs.org/zh/guide/installation.html)》官方: Node 版本要求: Vue CLI 需要 Node.js 8.9 或更高...

    10 个月前
  • 黄金搭档 -- JS 装饰器(Decorator)与Node.js路由


    1 年前


扫码加入 JavaScript 社区