Create a Wallet

To create a wallet we are going to use the /v1/generate endpoint to create a new wallet and then use the /v3/clients/me/signing-share-pairs endpoint to confirm successful storage of the generated signing share. Worth nothing that the generate endpoint returns MPC shares for both the SECP256K1 curve (compatible with EVM and Bitcoin chains) and the ED25519 curve (compatible with Solana). In other words, you only need to make one generate request to get wallets for multiple chains!

Steps

  1. From your application, make an HTTP POST request to https://mpc-client.portalhq.io/v1/generate using the clientApiKey you received in the previous step as the Bearer token.

curl -X POST 'https://mpc-client.portalhq.io/v1/generate' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer <clientApiKey>' \
    -d '{
        "metadataStr":"{\"clientPlatform\":\"CLI\",\"mpcServerVersion\":\"v6\",\"optimized\":true,\"performanceId\":\"\"}"
    }'

After sending this request you should get a 200 status code with a JSON response that looks like:

{
    "secp256k1": {
        "share": "{\"clientId\":\"\",\"backupSharePairId\":\"\",\"signingSharePairId\":\"clu3aue3j001fs60wdecyz0qy\",\"share\":\"42655232041390627786791902767749012498444759902802791166410397650285714231266\",\"ssid\":\"F3zm7gslQe7lyk+KzytU6zmkLq75o2c5thn3FamQ5fs=\",\"pubkey\":{\"X\":\"15818790871211280849066159414121693095427996293195244573907886767526096801083\",\"Y\":\"104656732396905250343538466741729090593967318924995079982799512400728937843942\"},\"partialPubkey\":{\"client\":{\"X\":\"41656442795325412261718684384921636215907688738791836875509123737161752369852\",\"Y\":\"40586975877543146125544682106295766473758531243046373745503751853695981016073\"},\"server\":{\"X\":\"46896489023891953329240027969352466433689328986698574266548802866023379758173\",\"Y\":\"19347710232419846850228368191943233470605329122521746447773383183461325013465\"}},\"allY\":{\"client\":{\"X\":\"99506185705129053257340319664880716165156428366688951040684287856725003230524\",\"Y\":\"92490623814207584758035084251494339764338290276328672031029176325364085038825\"},\"server\":{\"X\":\"104110005277740387680236603952282175413189909494653910221909064093493425407496\",\"Y\":\"114091842109454681061968635143922672909047641361778889235407762145305275255344\"}},\"p\":\"173754274424303621994885148689951347882306553709616804543050277026185097187969378348644197988676746748996530037426699910487957378977823578676219889340895883548521704164510481960755348024036729647492978108321293803346597613101134596130360493451965728164184119752253475162967466993762868322103183397288758156323\",\"q\":\"154540728036498182336802069225970259565279100278904397239418003579567169532777126177162912082940228735406343507799430601883331319560337908193519417331663715856940112297423398755718207113302066912016510375605341974773511259687179236712368178524369684405444020450957332444138061567339497151313302019019539161263\",\"pederson\":{\"client\":{\"n\":\"26852112068985377825863341136724391076603669764763768697116205783025751574979827745381184864757584436161587214216820339109323674472996133676095955547879199647914330395716411372979424372865466312329732408976197583229172207008746907470033727016419248893647223155229217836535133996641946854453922524750795262729690454202640851211823256140497164442771264238149612273832927748399258901138859011723677522941725507428267255265311942498785893528431038075623567509440256045546454204084820840093112345658491263155365753113236104212970517127545707329949888129131472803253679124651035833127851040565526519877002758730401660115949\",\"s\":\"13622260692570212152846055746486175484919962686214585666371895934192839561422553768997423663220432275450999647459258066235475824832438859054365188965635276999274525501458488573599707699757856108011375862919201323989809815732760639406908778115319044173445480558099492922962312742140565824463931480980692472738033099707286774058686643422252589915750709431391790286952151973928144263880631224747435129183943449747458828005106285758613834895536268646594215399570118141440703788754215948825143967853661692314885896327155655089279750622246106142309514289700408421035286716921638550986707162612415964763514305157897803006289\",\"t\":\"23528708411055544429689938323074591894290775319066349951706180335893726910619049351510651382027899209175677688322593371827674746767529788211540025312118718540372317579069102888325180002009427112076495509922994735939693760687230890548979920919991898796452859559729023006488000292066830614223104355249115556417639776444384086825326591767740191255576008831930410162879814218859332156425101142015187116805298240031902625744060885361690210158933591969535854947387259703040605521155084781519838913101064344959760562879047771544184753458612080526172277244175241072810815978684021772432318562343435000673289616550488505624541\"},\"server\":{\"n\":\"22148925588485459672070201509748719783072019752475651037754046321203173873556230883073668602363539937649299859025677296308288585070166740169432362886936813146605443657511271654363241102514397919423926471838676393895542178890418321845064412420770147102358738919992484211661458084202022883765256076776381598258053037982334500459709510837615757950836631519569183143363861199730162701576245303154318687843613784103967139449042747076918707323750535924687472132319717444401988267777832715166152611273398140134621018110255242407417362677581788429886622744028731937813079798708928603537700685790746175577144183872625589115181\",\"s\":\"13459757611056159150134008229527433518389666501857832585276716817110352030787404138719362849733084068446603662681938673682479290549146112401944869158162685146965817867604895916838128451958092143749708596218573965900429635226526384666976725329406326766883925518550578966054512790186628651629248404238641613775360040333458426705970005393362057326900185087120213357322940812875103254871346221453706297705196906975432713326878949273640672187308169586299701794744061580380817318450648984354669424912990926428514243991819202920981936371677583543082511069498265061314243989828866288773285540833946303437560556134759113178573\",\"t\":\"20386210996776228781859693548715824185992286703599254489351859955991352089193536861648307627438552523837014587919915217929056629945144629977199284071738797763607686574880583396310343402260297181094573796549125040501115835957573237211151375805437113681084033884793984860631109928022443907754917782794590408645641597710536185018861853402964406406274917087767103553548335389496935704646250210007918725835054933344580727159980433234011775795630925745456079991319398014762258764173052780544851421271205502158156004781084854284556824710105005327749535598346279566576542546838636514368501459202814711444738969043292099630928\"}},\"bks\":{\"client\":{\"X\":\"60770374368909903864249040583858737469021162421220562145823661034862765534104\",\"Rank\":0},\"server\":{\"X\":\"90573569823449142335959538281488654970530619978243901050688395597157593420399\",\"Rank\":0}}}",
        "id": "clu3aue3j001fs60wdecyz0qy"
    },
    "ed25519": {
        "share": "{\"clientId\":\"\",\"backupSharePairId\":\"\",\"signingSharePairId\":\"clu3auej6001ds60wqhh4tzgx\",\"share\":\"6967989490222286751193371200870222926916412847105191581545679272830570897147\",\"ssid\":\"pdQWQOkR5xjwxc6mtC4W6jaFnOED5qXUGQkzXeOE30k=\",\"pubkey\":{\"X\":\"24313799267958899186438243971529375224649671269617149625985536834152641122882\",\"Y\":\"31936172846620757498537682461075599896283629199737132786395301280718719059626\"},\"partialPubkey\":{\"client\":{\"X\":\"14875011030184865669272452692777338952321968107339354281685489672979868146992\",\"Y\":\"40348723006758513543518178435399769542897944655627102419100240577785172998050\"},\"server\":{\"X\":\"51770282909035768490141105722925385277522000949951602828871222913758614097867\",\"Y\":\"32848742230477067740784733427327280405386348193221183756833394352162643696341\"}},\"allY\":{\"client\":{\"X\":\"169111646600698723658356397332072100616011773655368052110642552471623313947\",\"Y\":\"31364235895172826103220109084775018717024101956335569140016270907279637292928\"},\"server\":{\"X\":\"50821740904638664322472018038634174316338947121275170051911742526518640222816\",\"Y\":\"2875180528960214804282325047914269462105066792934917444226250840711471711246\"}},\"p\":\"144071400668522930481451471362347143287035446552222523701093095888548275175718823775506508735927263288317305362447461069980791295271199596236290259966092657493264265874077801218621174005313268753786038492814396575358949079590561442030667354899165007610631311556623191623062222223700894638742606213348579589919\",\"q\":\"162648129158612311553461509465641412362209561636400119856730811205176788108732852563486749578322009817573757434702652340853235384166659516594351785645763410179872611217398704819719803146950036596407749643663418751685762256551505409330156508433854460361838705239357529173245009836682806126269325389472998629327\",\"pederson\":{\"client\":{\"n\":\"23432943783996101725184492866368124804922452154127015249823826354990024564846172411932495469072211342009419201525755859701623970064742479510509194569873375622501864745234188624710410317754372604378035378254003957551184613405585270558541645874532502045617495188098265810678411506994872132464886884059455432145562684432005868654786946645771759116428258552514452802018052346906200537924478551275111753707044980311408822959512902550173885329520403338889337730360315427107658579456547685302018325875277785801440983717767364568279157646835725619436019101286753907097473310639732185298642587312079804115987030385054746954513\",\"s\":\"21945573606490233609461141091772238860632568802198744100744145161149807569430302267690663583482323550658077816711755317699091629259239517873916860930794019932594605993836873967004383874677473348256376779509823853979211128391996362735861099974421924453713247820414738357981776275618329254892184528120810970218450575374179587331557174583521636749951759694074884637627671679374254931659478152474708803634498023610483741993269437185921994378853680908682271958371138020774376904367126054592697528331857404003646838466420274715530010719791731546490892028822736600723220591210962634234991307297073855069014797513829626749545\",\"t\":\"11707961303902828157561434690470306321316422124469280253379064314567448955032565768659853784321474684165567320310930240119027958795119352971105111425714087982748051889292911219139232226929253843062034654618739471764562062051602122833965104905897308675109408817428926888912414092970170961192077373081090902462526721591602666225583627576790569037171382695409037200876060276943475318048958249650689144613061482483997823351672122244244209043943004993120696119906993564121617096005487728453372182398603500514656831859324855835566829594270949911252708140085270573555403559777321329310194342504431712328984321599053732694526\"},\"server\":{\"n\":\"30981685644839548967083696211487766327501977809036952348319738494666562628732324265101928063733113386575457630097287441642254941357199553327848261699408748114079114190567625310054406401970985130759041222504797668847149084402748713922817250709809003180796616990025396988479825731614875914642738018413739685515983556384814568467017631009994192194958786304394116544392718226460230740260035317341701777520762751558218827658802484851503906505430357804103040737122502074558771394107382730381318583778081571835797260499362835324610387600690698528274174855591205887218746286230057670463832298763932595547357502856001177382409\",\"s\":\"4231886941570277548482841468810487684201999321959213252573705813185093304339314376738381128249428023764246233962959589847463502204029663557525610826864063946662899264766090993958460188963076253931203609402901777128327071062037003775393673478293907386143350563429308664779743552196516512731020334845741981043493363965198112464625171581042950204153065098207185728741062255863289264471786072771155151803500527822553227106303795132571628985185522588571296714946725577438008643117056789456610999000843910592771899954198178128340685908404267686066442167624014114208672962609404658765656737977012039454467341372305820376735\",\"t\":\"17952073725031180307577101008845712811223115413201437191937229527605100819981402748021808066881703680614448463115974400538177004620008192715939877906679255798546175792061548635324843027550961311972619017222274317556188540315531105888151325105290351694513404504774079079056762922312998349811306219090961880097385344945564195195316102215322776787017058991286235666300512280326420115816388067467358497916307353724661043026390755658190547740640028026923193418797993225022249860216724214044828912665617452640471849578661646859043102247081032891014644625232501238887509397175626210951726617946172420370103024234292534096857\"}},\"bks\":{\"client\":{\"X\":\"801269190048086114006337416115308562518221691939864671786713834424254624618\",\"Rank\":0},\"server\":{\"X\":\"1682500115561369620486410312037446164305222091161725465732942722455141148780\",\"Rank\":0}}}",
        "id": "clu3auej6001ds60wqhh4tzgx"
    }
}
  1. Returned in this request is the share and id of that share for each respective curve! In your production build youโ€™ll store the full object that is returned, generateReponse, in a secure location. For this guide, just save this value for Signing.

  2. As a wallet safeguarding measure, we require the client to notify our backend once they have successfully stored their signing share (in either a keychain or DB). To do this, just make a single PATCH request to /api/v3/clients/me/signing-share-pairs with the signingSharePairIds you get from the generate response and a "STORED_CLIENT" status.

const SECP256K1_SHARE_ID: string = response.secp256k1.id
const ED25519_SHARE_ID: string = response.ed25519.id
curl -X PATCH 'https://api.portalhq.io/api/v3/clients/me/signing-share-pairs' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer <clientApiKey>' \
    -d '{
      "status": "STORED_CLIENT",
      "signingSharePairIds": ["SECP256K1_SHARE_ID", "ED25519_SHARE_ID"]
    }'

This will return a 204 on success.

Congrats! ๐ŸŽ‰ You have now created your first Portal wallet and are ready to sign a transaction!

Last updated