Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Recommendations
Filter
Develop Samsung Wallet
doctechnical support url https //developer samsung com/dashboard/support
Develop Samsung Blockchain
docconnect with hardware wallet samsung blockchain platform sdk supports various cold wallets it can be managed using hardwarewalletmanager, and can get an instance from sblockchain currently, there are two types of hardwarewallet, samsung blockchain keystore and the ledger nano get instance gethardwarewalletmanager is a callable instance of sblockchain if the sblockchain instance is not initialized, an illegalstateexception will be thrown try { hardwarewalletmanager hardwarewalletmanager = sblockchain gethardwarewalletmanager ; } catch illegalstateexception e { // handling exception } connect the hardwarewallet should be connected to sign, create, or restore an account the connect api requires two mandatory parameters, hardwarewallettype and whether to clear the saved accounts the hardwarewallettype is used to target its connection there are two connection types usb and bluetooth, and is specific for the ledger nano x for usb connections, the device must be connected through otg a bonding state is required for bluetooth connections to connect a ledger device, the latest ethereum application is installed on the ledger device and can be connected while running if ready to connect, the connect api can be called listenablefuturetask<hardwarewallet> connectiontask = hardwarewalletmanager connect hardwarewallettype, true ; connectiontask setcallback new listenablefuturetask callback<hardwarewallet> { @override public void onsuccess hardwarewallet hardwarewallet { } @override public void onfailure executionexception e { throwable cause = e getcause ; if cause instanceof hardwarewalletexception { // handling hardware wallet error } else if cause instanceof rootseedchangedexception { // handling root seed changed exception } } @override public void oncancelled interruptedexception e { } } ; the parameters to take note of are as follows hardwarewallettype target hardwarewallet to connect reset whether to clear accounts samsung blockchain platform sdk only supports one root seed for each hardwarewallet for account management if the root seed is changed by resetting the hardwarewallet, when the connect api is called, onfailure is called and the rootseedchangedexception is returned disconnect disconnect api is related to the target connection of the hardwarewallet it is recommended to call it before closing your application or even before connecting to another hardwarewallet if the disconnect api is not called, the broadcast receiver may continue to work hardwarewalletmanager disconnect hardwarewallet ; get connected hardwarewallet getconnectedhardwarewallet api returns an instance of the connected hardwarewallet apis that use the root seed requires an instance of connected hardwarewallet, so they can get the hardwarewallet connected and call it before calling them if no hardwarewallet is connected, a null is returned hardwarewallet connectedhardwarewallet = hardwarewalletmanager getconnectedhardwarewallet ; get supported coins hardwarewallet instance is returned through the hardwarewalletmanager that has apis that support its feature getsupportedcoins api returns a list of cointype provided by the hardwarewallet and samsung blockchain platform sdk in common list supportedcointypes = hardwarewalletmanager getconnectedhardwarewallet getsupportedcoins ; stringbuilder sb = new stringbuilder ; sb append “supported coins ” append ‘\n’ ; for cointype cointype supportedcointypes { sb append ‘[’ append cointype code append ‘ ’ append ‘\n’ ; } string s = sb tostring ; get version getversion api returns its version for samsung blockchain keystore, it returns the versionname of the keystore; and for the ledger it returns the version of the ledger application running if you need a different behavior depending on the version, you can call this api to branch hardwarewallet connectedhardwarewallet = hardwarewalletmanager getconnectedhardwarewallet ; string version = connectedhardwarewallet getversion ; get connection state isconnected api returns the state that the hardwarewallet instance is connected if connected, it returns as true otherwise, it returns as false if hardwarewallet isconnected { hardwarewalletmanager disconnect hardwarewallet ; }
Develop Samsung Pay
docapi reference this page describes the data structures used in the samsung pay web checkout api integration paymentmethods the paymentmethods object defines the payment methods that the merchant supports key type required description version string required samsung pay api versionthe supported value is 2 serviceid string required merchant id that is assigned after onboarding protocol string required payment protocol typethe supported value is protocol_3ds allowedbrands list<string> required list of supported card brandsthe possible values are visamastercardamexdiscoverelomadacbjaywan tbd isrecurring boolean optional value if payment is recurringthe default value is false isbillingaddressrequired boolean optional value if billing address must be included in the payment credentials the default value is false iscardholdernamerequired boolean optional value if cardholder name must be included in the payment credentials the default value is false iscpfcardrequired boolean optional value if cpf must be included in the payment credentials the default value is false merchantchoicebrands object optional data structure containing configuration information for a co-badged card merchantchoicebrands type string required co-badged card display option for the payment sheetthe possible values are mandatory = only the brand defined in merchantchoicebrands brands is enabledpreference = the brand defined in merchantchoicebrands brands is selected by default but the user can change it merchantchoicebrands brands list<string> required list of supported brands for the co-badged cardthe possible values are madacb extrapaymentinfo object optional data structure containing additional supported features extrapaymentinfo id string required feature id for the additional featurethe possible values are combocard = combo carddsrp = digital secure remote payment extrapaymentinfo type string optional feature type, if the value of extrapaymentinfo id is dsrpthe possible values are ucaf = universal cardholder authentication fieldicc = integrated circuit cardthe default value is ucaf table 1 "paymentmethods" data structure elements transactiondetail the transactiondetail object contains the transaction information for the user's purchase key type required description ordernumber string required order number of the transactionthe following characters are allowed [a-z][a-z][0-9,-] merchant object required data structure containing merchant information merchant name string required merchant name merchant url string required merchant domain urlthe maximum length is 100 characters merchant id string optional merchant referencethis is the id value registered with your pg required for gateway token mode the maximum length is 45 characters it should be set in the request parameter for mada token if a merchant request mada token, this field is mandatory as this field should be included in the payload for mada token, there is a 15-character length limit merchant countrycode string required merchant country codeiso-3166-1 alpha-2 amount object required data structure containing the payment amount amount option string required display format for the total amount on the payment sheetthe possible values are format_total_estimated_amount = display "total estimated amount " and total amountformat_total_price_only = display the total amount only amount currency string required currency codethe maximum length is 3 characters amount total string required total payment amount in the currency specified by amount currencythe amount must be an integer for example, 300 or in a format valid for the currency such as 2 decimal places after a separator, for example, 300 50 type string optional transaction typethis value is specifically supported for mada tokens and will not apply to other token types the possible values are purchasepreauthorizationthe default value is purchase table 2 "transactiondetail" data structure elements paymentcredential the paymentcredential object contains the payment credential information generated by the samsung wallet application on the user's mobile device key type required description card_brand string required brand of the payment card card_last4digit object required last 4 digits of the card number 3ds object required data structure containing the generated 3ds data 3ds type string optional 3ds typethe value is s for samsung pay 3ds version string required 3ds versionthe value for the current version is 100 3ds data string required encrypted payment credential data recurring_payment boolean required value if credential is enabled for recurringthe default value is false encryptedmessage string conditional encrypted string jwe that contains billing address, cardholder name and cpf when required by partner it can be decrypted in the same way as payment credentials table 3 "paymentcredential" data structure elements encryptedmessage the decrypted encryptedmessage object in paymentcredential object contains billing address, cardholder name and cpf when required by partner key type required description billingaddress object conditional billing address billingaddress addressline1 string required address line 1 billingaddress addressline2 string optional address line 2 billingaddress city string required city billingaddress state string optional state billingaddress countrycode string required country code iso 3166-1 alpha-3 billingaddress postalcode string required postal code cardholdername string conditional cardholder name cpf object conditional brazilian cpf cpf name string required the full name of the individual associated with the cpf cpf number string required the brazilian taxpayer number cpf , consisting of exactly 11 digits, without hyphens or dots table 3-1 "encryptedmessage" data structure elements paymentresult the paymentresult object contains the payment result information during transaction processing, and after the payment is processed with pg network key type required description status string required payment statusthe possible values are charged = payment was charge successfullycanceled = payment was canceled by either user, merchant, or acquirerrejected = payment was rejected by acquirererred = an error occurred during the payment process provider string optional payment provider pg name table 4 "paymentresult data structure elements
Develop Samsung Pay
docinbound general contract base url https //s2p-api mpay samsung com/ext/v1 security mutual ssl is required common headers header name type validation description request-id uuid required unique identifier for the request partner-id uuid required unique identifier that is provided to partner during onboarding partner-id uuid required request-id echoed back in the response headers common http error codes http code description application code message 400 bad request 400 1 invalid data 500 internal server error 500 1 internal server error 503 service not available 503 1 service temporarily unavailable retry-after header is required 503 service not available 503 2 api temporarily unavailable retry-after header is required registration partner server registers a session for the user as a result, a unique registration id will be generated partner server should make sure that this is called only once for one card a welcomeurl will also be returned partner server can display the welcomeurl in browser or email upon rendering, a qr code will be displayed and users can use their spay wa to scan the qr code welcomeurl has an expiration date, partner server should check if it's still valid before rendering if it's expired, a get call will return the new url request post /registrations body registration email description user email address type string validation optional example registration enforceemailmatching description enforce only spay wa with the same email address can provision enforcement is only against the email address that's provided by the partner type boolean default is false validation optional example true registration hideemail description hide email field type boolean default is false validation optional example registration phone description user phone number type phonenumber validation optional example registration enforcephonematching description enforce only spay wa with the same phone number can provision enforcement is only against the phone number that's provided by the partner type boolean validation optional default is false example true registration hidephone description hide phone field type boolean validation optional default is false example registration welcomecallbackurl description callback url that the welcome ui will redirect to once the user successfully linked a spay wa account type url validation optional example registration allowofflinecommunication description if true, s2p will communicate to the user via email and/or phone number to facilitate the provisioning process type boolean validation optional default is false example registration data description arbitrary data blob that'll be passed to the device when an account is linked type object validation optional example registration custom cardname description card name that'll show on the welcome page type string validation required example registration custom cardarturl description cardart url that'll show on the welcome page type url validation required example registration custom partnername description partner name that'll show on the welcome page type string validation required example registration custom partnerlogourl description partner logo url that'll show on the welcome page type url validation required example registration custom partnertncurl description partner tnc url that'll show on the welcome page type url validation optional example response status http/1 1 201 created header name value content-type application/json body registration id description registration id that identify this session type uuid validation required example registration status description registration status type enum - pending, linked validation required example pending registration welcomeurl description this is the url that partner can show to the user as an iframe a separate page it shows the qrcode and optionally user can enter email and phone number type url validation required example registration welcomeurlexpiration description welcomeurl expiration timestamp in milliseconds type timestamp validation required example example post /ext/v1/registrations { "email" "user@gmail com", "enforceemailmatching" true, "phone" "14089998888", "enforcephonematching" true, "custom" { "cardname" "xyz bank credit card", "cardarturl" "https //xyz com/cardart png", "partnername" "xyz bank", "partnerlogourl" "https //xyz com/logo png" } } http/1 1 201 created { "id" "395ce2e29485442cbd9bacdc77105126", "welcomeurl" "https //s2p stg mpay samsung com/v1/welcome/eyjlbmmioijbmju2r0nniiw iywxnijoizglyin0 s0dnxrskdkjw8sbh kg4uqhfwkkdnqrviihkaqshq_jayb99ct tizdzrwrn-qlhuzj4imuyv1sagehavyxluamarwa tlekqcerr0jklc-fnqkcva", "status" "pending", "welcomeurlexpiration" 1505953396844 } get registration check existing registration status and/or get new welcomeurl request get /registrations/{regid} headers name value validation partner-id partner id value assigned by samsung wallet required response status http/1 1 200 ok status name value content-type application/json body registration id description registration id that identify this session type uuid validation required example registration status description registration status type enum - pending, linked validation required example pending registration welcomeurl description this is the url that partner can show to the user as an iframe a separate page it shows the qrcode and optionally user can enter email and phone number type url validation required example registration welcomeurlexpiration description welcomeurl expiration timestamp in milliseconds type timestamp validation required example example http/1 1 200 ok { "id" "395ce2e29485442cbd9bacdc77105126", "welcomeurl" "https //s2p stg mpay samsung com/v1/welcome/eyjlbmmioijbmju2r0nniiw iywxnijoizglyin0 s0dnxrskdkjw8sbh kg4uqhfwkkdnqrviihkaqshq_jayb99ct tizdzrwrn-qlhuzj4imuyv1sagehavyxluamarwa tlekqcerr0jklc-fnqkcva", "status" "pending", "welcomeurlexpiration" 1505953396844 } errors common http error codes http code description application code message 400 bad request 400 1 invalid data 500 internal server error 500 1 internal server error 503 service not available 503 1 service temporarily unavailable retry-after header is required 503 service not available 503 2 api temporarily unavailable retry-after header is required
Develop Samsung Wallet
docevent ticket 'event ticket' cards support event commodities for performances, sports, movies, entrances, and etc event tickets in wallet can provide additional information about the event and an alarm before the event time and expiration ticket cards support event commodities for performances, sports, movies, and entrance wallet card type wallet card type wallet card subtype ticket performances, sports, movies, entrances, others performances movies sports entrances wallet card data fields attributes type value description attributes {fields} title string 32 required main title e g , mlb ticket category string 16 optional ticket category * this will be deprecated eventid string 32 optional if full cancelation of the event occurs, find and process all tickets with this id groupingidstring 32 optional identifier used to group related cards orderidstring 32 optional a unique identifier for an order mainimg string 256 required url for main ticket image the file size should not exceed 512 kb subtitle1 string 32 optional the auxiliary field which displays supporting information logoimagestring 256 required logo image url to be displayed in the card item the file size should not exceed 256 kb logoimage darkurlstring 256 required logo image url in dark mode the file size should not exceed 256 kb logoimage lighturlstring 256 required logo image url in light mode the file size should not exceed 256 kb wideimagestring 256 optional wide horizontal image url displayed on the card information screen the file size should not exceed 256 kb providername string 32 required ticket provider name providerviewlinkstring 512 optional link to additional information from the provider* see links format classificationstring 16 optional classification of tickets use onetime, regular, or annual * default onetime holdernamestring 64 optional name of card holders idphotostring 20k optional holder’s photo image data encoded base64 idphoto format string 32 optional image file formate g , jpeg, png * unsupported image formats may exist idphoto status string 16 optional status of the dataallowed value unchanged gradestring 32 optional ticket grade seatclassstring 32 optional seat class entrancestring 64 optional entrance gate seatnumber string 256 optional seat location seatlayoutimage string 256 optional url of the seat layout image the file size should not exceed 512 kb issuedatelong 13 required issue date epoch timestamp in milliseconds reservationnumberstring 32 required reservation number userstring 64 optional name of person who made the reservation certification string 16 optional ticket certification e g ,r, as a film rating reactivatableynstring 1 optional flag whether the card is able to activate an expired ticket temporarily either 'y' or 'n' * default 'n' preventcaptureyn string 1 optional flag whether this wallet card view prevents screen capture either 'y' or 'n'* default 'n' nonetworksupportyn string 1 optional set whether to support to open the wallet card under 'no network' status either 'y' or 'n' * default 'n' startdate long 13 required start date displayed start date epoch timestamp in milliseconds startdate utcoffset string 8 optional utc offset of start date time at the event location enddate long 13 optional end date displayed end date epoch timestamp in milliseconds * if null, the card will expire in 10 hours from startdate enddate utcoffsetstring 8 optional utc offset of start date time at the event location person1 string 512 optional number of persons by category * see classification format locationsstring 1024 optional list of locations where the card can be used * see location format noticedesc string 5000 required text of the notice * long content is allowed * see additional information format groupinfo1 string 64 optional the first common information with the same groupingid groupinfo2 string 64 optional the second common information with the same groupingid *it is recommended to set groupinfo1 first groupinfo3 string 64 optional the third common information with the same 'groupingid' *it is recommended to set groupinfo1, groupinfo2 first csinfostring 512 optional providers’ customer service informationusing data in json format converted to escape string * allowed items call, email, website, facebook, youtube, or instagram* see the example below privacymodeynstring 1 optional whether or not to require user authentication when using the cardeither ‘y’ or ‘n’* default ‘n’ applinklogo string 256 required app link image url the file size should not exceed 256 kb applinknamestring 32 required app link name applinkdatastring 256 required information about the partner app link bgcolor string 8 optional color of the card art e g , #00ffff fontcolor string 8 optional color of the font on the card art acceptable values dark, light blinkcolorstring 8 optional color of the blinking effect in the indicator areae g , #00ffff barcode value string 4096 optional actual data that is delivered when the barcode/qr code is scanned barcode serialtype string 32 optional presentation type e g , serialnumber, barcode * see barcode format barcode ptformat string 32 optional presentation format e g , barcode, qrcode, serial * see barcode format barcode ptsubformat string 32 optional presentation sub-format e g , code_128, qr_code * see barcode format barcode errorcorrectionlevel string 4 optional amount of redundancy or error correction data included in the code there are four error correction levels available in qr codes * code options l/m/q/h barcode intervalstring 4 optional update interval if support for dynamic updatesepoch timestamp in milliseconds provision data string 512 optional elements to complete provisioning* see provisioning for details provision interval string 16 optional update interval if support for dynamic updates epoch timestamp in milliseconds relcoupon{i} title string 32 conditional coupon title * required if this ticket has a related couponi 1~3 relcoupon{i} subtitle string 32 optional coupon subtitlei 1~3 relcoupon{i} providername string 32 conditional coupon provider name * required if this ticket has a related coupon i 1~3 relcoupon{i} imagefilesrc string 256 optional coupon image url the file size should not exceed 256 kb i 1~3 relcoupon{i} noticedescription string 1024 optional text of the notice * long content is allowed * see additional information format i 1~3 relcoupon{i} notificationtime long 13 optional coupon exposure time epoch timestamp in milliseconds i 1~3 relcoupon{i} value string 4096 conditional actual data that is delivered when the barcode/qr code is scanned i 1~3 relcoupon{i} serialtype string 32 required presentation typee g , serialnumber, barcode, * see barcode format i 1~3 relcoupon{i} ptformatstring 32 conditional presentation formate g , barcode, qrcode, serial, * see barcode format i 1~3 relcoupon{i} ptsubformat string 32 conditional presentation sub-formate g , code_128, qr_code, * see barcode format i 1~3 relcoupon{i} errorcorrectionlevel string 4 optional amount of redundancy or error correction data included in the code there are four error correction levels available in qr codes - code options l/m/q/h i 1~3 example { "card" { "type" "ticket", "subtype" "entrances", "data" [ { "refid" "ent-ticket-0613001", "createdat" 1686657600000, "updatedat" 1686657600000, "language" "en", "attributes" { "title" "galaxy land entrance ticket", "subtitle1" "standard", "classification" "annual", "groupingid" "group-0613001", "orderid" "ent-0613001", "mainimg" "https // /main png", "logoimage" "https // /logo png", "providername" "galaxy entertainment", "logoimage darkurl" "https // /logo-dark png", "issuedate" 1686657600000, "reservationnumber" "glx-0613-001", "startdate" 1686657600000, "enddate" 1718280000000, "holdername" "kim eunha", "idphoto data" "base64-encoded{image-file-data}", "idphoto format" "png", "grade" "family", "person1" "{\"person\" [{\"category\" \"adult\", \"count\" 1 }]}", "locations" "[{\"lat\" 37 256518, \"lng\" 127 053516, \"address\" \"samsung-ro yeongtong-gu, suwon\", \"name\" \"galaxy land central park\"}]", "noticedesc" "{\"count\" 2,\"info\" [{\"title\" \"notice 1\",\"content\" [\"description 1-1\",\"description 1-2\"]},{\"title\" \"notice 2\",\"content\" [\"description 2-1\"]}]}", "groupinfo1" "adult 1", "groupinfo2" "standard", "groupinfo3" "family", "csinfo" "{\"call\" \"0000-0000\",\"email\" \"samsungwallet@samsungwallet com\",\"website\" \"https //www samsungwallet com/cs/\",\"instagram\" \"https //www instagram com/samsungwallet\",\"youtube\" \"https //www youtube com/@samsungwallet\",\"facebook\" \"https //www facebook com/samsungwallet\" }", "applinkname" "galaxy ticket", "applinklogo" "https // /applinklogo png", "applinkdata" "https //www applinkdata com", "bgcolor" "#e86d1f", "fontcolor" "light", "blinkcolor" "#e86d1f", "barcode value" "serial-0613-001", "barcode serialtype" "qrcode", "barcode ptformat" "qrcodeserial", "barcode ptsubformat" "qr_code" }, "localization" [ { "language" "ko", "attributes" { "title" "갤럭시 랜드 입장권", "holdername" "김은하", "person1" "{\"person\" [{\"category\" \"어른\", \"count\" 1 }]}", "locations" "[{\"lat\" 37 256518, \"lng\" 127 053516, \"address\" \"samsung-ro yeongtong-gu, suwon\", \"name\" \"갤럭시 랜드 센트럴 파크\"}]", "noticedesc" "{\"count\" 2,\"info\" [{\"title\" \"공지사항 1\",\"content\" [\"설명 1-1\",\"설명 1-2\"]},{\"title\" \"공지사항 2\",\"content\" [\"설명 2-1\"]}]}", "groupinfo1" "어른 1" } } ] } ] } }
Develop Samsung Pay
docintroduction detailed flow step 1 → 2 partner server is ready to show the user the "add to spay ui" partner server registers to save2pay and gets a regid and welcomeurl back regid uniquely identifies this session and should be cached by partner server and used throughout the entire flow welcomeurl provides the ui to lead the user to add the card to spay step 3 the partner server shows the welcome ui on the browser, presumably in an iframe the welcome ui would show qr code as well as necessary instructions step 4 user launches spay wa and scans the qr code displayed on the welcome ui if spay wa was not installed, the instructions on welcome ui would lead the user to download the app if necessary , register samsung account and login into the spay client step 5 → 6 the spay wa qr scanner would attempt to invoke the url embedded in the qrcode, more specifically the "initiate" request to save2pay server the server verifies the payload and notifies partner server that the spay wa is ready device specific information such as the device id, wallet id & user id will also be sent this step essentially links the samsung account with the regid the welcome ui would also show a message indicating the linking is successful step 7 → 8 partner server talks to the issuer to pre-provision the card and get encrypted issuerblob step 9 partner server returns the issuerblob in the notify response the issuerblob will be encrypted and can only be decrypted by the issuer server the blob will also have device and wallet specific information so it can only be provisioned to the device that made the 'initiate' request the exact format of the issuerblob depends on the issuer step 10 the issuerblob and additional information are returned to the device in the 'initiate' response steps 11 → 16 spay wa would go through the normal tokenization flow to add the token into spay using the issuerblob step 17 spay wa report to s2p server that the provision is completed for this regid step 18 s2p notifies partner server that provisioning is completed for this regid data types type json type format description string string size 2048 boolean boolean object object enum string pattern [a-za-z0-9_]{1,256 values from a limited set are only allowed each field of type enum will define the values allowed phonenumber string pattern [0-9+ -]+ uuid string pattern [a-za-z0-9-_]{26,128} unique identifie url string size 2048 must be an absolute url defined by rfc 2396 uniform resource identifiers uri generic syntax supported schemes - http, https timestamp number int64 - signed 64 bits unix epoch time in milliseconds countrycode string size 2 unique identifie
Learn Code Lab
codelabdevelop a blockchain shopping app objective create a shopping application with samsung blockchain platform sdk and pay using ethereum network overview the blockchain industry is expanding in many ways it is growing the most as a means of payment samsung blockchain platform sdk helps to make payments easily with cryptocurrency you can interact with blockchain through a simple api call to create a transaction in this code lab, you can pay for a product using the ethereum network in a simple shopping app, which is a decentralized application dapp dapps run and store data on the blockchain network instead of a central server set up your environment you will need the following java se development kit 8 or later android studio latest version recommended mobile phone with samsung blockchain sample code here is a sample code for you to start coding in this code lab download it and start your learning experience! platform sdk sample code 3 94 mb enable developer mode to activate developer mode on your mobile device, follow the steps below navigate through settings > biometrics and security > samsung blockchain keystore and click about blockchain keystore tap the samsung blockchain keystore app name quickly, ten times or more if succeeded, developer mode will show import project file open the downloaded sample code containing the shopping app project go to file > open and select the open file or project window every gui resources are already included in the provided project you simply need to fill out the code by following the next steps moreover, it is recommended to go through the documentations of samsung blockchain platform sdk initialize the instance create an sblockchain instance this is the first step since sblockchain is the initial base class of sdk along with that are hardwarewalletmanager responsible for wallet operations accountmanager responsible for account operations msblockchain = new sblockchain ; msblockchain initialize mcontext ; maccountmanager = msblockchain getaccountmanager ; mhardwarewalletmanager = msblockchain gethardwarewalletmanager ; mcoinnetworkinfo = new coinnetworkinfo cointype eth, ethereumnetworktype goerli, rpcurl ; connecttokeystore ; connect to samsung blockchain keystore you can get hardware wallet instance from hardwarewalletmanager hardwarewallettype refers to the type of cold wallet to be connected, such as samsung blockchain keystore and ledger nano s mhardwarewalletmanager connect hardwarewallettype samsung, false setcallback new listenablefuturetask callback<hardwarewallet> { @override public void onsuccess hardwarewallet hardwarewallet { handler post new runnable { @override public void run { log i tag,"hardwarewallet is connected successfully" ; mprogressbar setvisibility view invisible ; setaccountstatus ; } } ; } @override public void onfailure @notnull executionexception e { mprogressbar setvisibility view invisible ; e printstacktrace ; } @override public void oncancelled @notnull interruptedexception e { mprogressbar setvisibility view invisible ; e printstacktrace ; } } ; the second parameter of connect api refers to reset if you do not want to reset the wallet then keep it false, otherwise true manage your account now, your shopping dapp is connected to the keystore it means that if you have your own account with balance, you can now buy using ether or eth let’s create an ethereum account to be used for payment for generating a new account with samsung blockchain platform sdk you need an instance of the accountmanager from sblockchain accountmanager provides methods for fetching, creating, restoring accounts, and other more once you have an instance of accountmanager, you can call generatenewaccount as shown below it has methods regarding accounts such as get, create, and restore refer to the samsung blockchain platform sdk documentations for more details hardwarewallet connectedhardwarewallet = mhardwarewalletmanager getconnectedhardwarewallet ; if connectedhardwarewallet != null { try { maccountmanager generatenewaccount connectedhardwarewallet, mcoinnetworkinfo get ; } catch interruptedexception e { e printstacktrace ; } catch executionexception e { e printstacktrace ; } } if an account is already created, textview is shown at the top of the app and the create account button is disabled to prevent further account creation list<account> accounts = maccountmanager getaccounts null, cointype eth, ethereumnetworktype goerli ; if !accounts isempty { methereumaccount = ethereumaccount accounts get accounts size - 1 ; tvaccountstatus settext methereumaccount getaddress ; btncreateaccount setenabled false ; } get instance for ledger service after creating an account, you can use it for payment in your shopping dapp each coin blockchain ledgers has its own system to be stored in blocks samsung blockchain platform sdk provides abstracted api sets to developers for signing and sending supported cryptocurrency transactions over the blockchain network create coinservicefactory and just use any ledger you want in this scenario, use ethereumservice ethereumservice service = ethereumservice coinservicefactory getcoinservice mcontext, mcoinnetworkinfo ; at this point, your shopping dapp is ready to provide payment methods working on ethereum notebefore the next step, you need at least one valid ethereum account show payment sheet when a user selects an item, the app should show the payment screen it must show “who will pay how much amount of ether to whom” in the blockchain world, ethereum ledgers require more information, such as transaction nonce, to record that transaction into ledgers with samsung blockchain platform sdk, developers can do everything needed to show the payment sheet, intent should be created, which is to call the payment activity on click event of product object fill the parameters required and startactivityforresult to show a payment sheet item item = itemlist get position ; biginteger price = ethereumutils convertethtowei item getprice ; ethereumservice service = ethereumservice coinservicefactory getcoinservice mcontext, mcoinnetworkinfo ; hardwarewallet connectedhardwarewallet = mhardwarewalletmanager getconnectedhardwarewallet ; intent intent = service createethereumpaymentsheetactivityintent mcontext, connectedhardwarewallet, ethereumtransactiontype eip1559, methereumaccount, sample_to_adderss, price, null, null ; startactivityforresult intent, 0 ; get ether from faucet you need money when you buy something a free faucet site is provided to get ether if you have an ethereum account, just go to webview fragment and press send me eth button see the result of transaction if the payment was performed successfully from the payment screen, the result of transaction can be received from onactivityresult if the transaction is performed properly, you can find the result_ok at resultcode from the intent, a txid is shown which can be used to check your transaction’s status call gettransactiondetail txid string api method in ethereumservice and check the block# if there’s any valid countable number, your transaction is stored in blocks successfully and the payment is done if you can’t find it, just wait it’s processing among ethereum nodes alternatively, simply find the txid in goerli testnet explorer run the project you have created and verify that it works properly open the app and select the product from the list in the payment screen, select the fee to pay to the ethereum network and confirm the transaction then, check the result of the generated transaction sample images of the app screen can be seen below you're done! congratulations! you have successfully achieved the goal of this code lab now, you can develop a shopping dapp using samsung blockchain platform sdk by yourself! if you're having trouble, you may download this file platform sdk complete code 3 95 mb to learn more about developing apps with samsung blockchain, visit developer samsung com/blockchain
Learn Code Lab
codelabtransfer erc20 token with blockchain app objective develop a decentralized application dapp to transfer erc20 tokens between ethereum accounts using samsung blockchain platform sdk overview blockchain technology has been creating a significant impact in multiple sectors, such as banking, cybersecurity, and supply chain management it is widely used as a means of secure payment between different parties samsung blockchain platform sdk brings developers and consumers to the blockchain world by providing a complete set of functions that the decentralized app dapp or blockchain app needs ethereum is a decentralized blockchain network where you can perform transactions using its native currency, ether, and token you can interact with the network through simple api calls provided by the sdk for detailed information, see samsung blockchain platform sdk set up your environment you will need the following java se development kit 8 or later android studio latest version recommended samsung galaxy device that supports samsung blockchain sample code here is a sample code for you to start coding in this code lab download it and start your learning experience! token transaction sample code 2 73 mb enable developer mode to activate developer mode on your mobile device, follow the steps below navigate through settings > biometrics and security > samsung blockchain keystore and click about blockchain keystore tap the samsung blockchain keystore app name quickly, ten times or more if succeeded, developer mode will show start your project after downloading the sample code containing the project files, in android studio, click open to open the existing project locate the downloaded android project codelab-send-token-transaction-blank-code from the directory and click ok noteuser interface ui resources are already included in the provided project simply apply the code in the next steps in this code lab moreover, going through the sdk document is recommended initialize the instance since sblockchain is the initial base class of the samsung blockchain platform sdk, the first thing you need to do is create an sblockchain instance along with that, create the following in sendtokenfragment java hardwarewalletmanager for wallet operations accountmanager for account operations ethereumservice for transactions msblockchain = new sblockchain ; try { msblockchain initialize mcontext ; } catch ssdkunsupportedexception e { e printstacktrace ; } maccountmanager = msblockchain getaccountmanager ; mhardwarewalletmanager = msblockchain gethardwarewalletmanager ; mcoinnetworkinfo = new coinnetworkinfo cointype eth, ethereumnetworktype goerli, rpcurl ; mcoinservice = coinservicefactory getcoinservice getcontext , mcoinnetworkinfo ; ethereumservice = ethereumservice mcoinservice; connecttohardwarewallet ; connect to samsung blockchain keystore connect the app to the hardware wallet, which, in this case, is the samsung blockchain keystore you can get a hardware wallet instance from hardwarewalletmanager if you want to reset the wallet, set the second parameter of connect api to true otherwise, set it to false mhardwarewalletmanager connect hardwarewallettype samsung, false setcallback new listenablefuturetask callback<hardwarewallet> { @override public void onsuccess hardwarewallet hardwarewallet { handler post new runnable { @override public void run { log i tag, "hardwarewallet is connected " ; mprogressbar setvisibility view invisible ; getaccount ; } } ; } @override public void onfailure @nonnull executionexception e { mprogressbar setvisibility view invisible ; log e tag, "hardwarewallet connection failed " + e ; } @override public void oncancelled @nonnull interruptedexception e { mprogressbar setvisibility view invisible ; log e tag, "hardwarewallet connection cancelled " + e ; } } ; generate new account samsung blockchain platform sdk manages the address on blockchain as an account it contains the information required for signing and the blockchain address accountmanager provides apis dedicated for fetching, creating, and restoring accounts use generatenewaccount api for the creation of a new ethereum account upon clicking the create account button in the app hardwarewallet connectedhardwarewallet = mhardwarewalletmanager getconnectedhardwarewallet ; maccountmanager generatenewaccount connectedhardwarewallet, mcoinnetworkinfo setcallback new listenablefuturetask callback<account> { @override public void onsuccess account account { mprogressbar setvisibility view invisible ; log i tag, "generate new account successful " + account ; handler post new runnable { @override public void run { getaccount ; } } ; } @override public void onfailure @nonnull executionexception e { mprogressbar setvisibility view invisible ; log e tag, "generate new account failed " + e ; } @override public void oncancelled @nonnull interruptedexception e { mprogressbar setvisibility view invisible ; log e tag, "generate new account cancelled " + e ; } } ; after creating a new account, call the getaccounts api to get the account list if you already have an account, the textview will show the account's address and the create account button will be disabled in the app accounts = maccountmanager getaccounts null, cointype eth, ethereumnetworktype goerli ; if !accounts isempty { methereumaccount = ethereumaccount accounts get accounts size - 1 ; showaccounttextview settext methereumaccount getaddress ; generateaccountbutton setenabled false ; } create a token account to perform a token transaction, add the token address with the corresponding ethereum account and create a token account by calling the addtokenaddress api use the generated token account to perform token-related actions an ethereum account can add one or more tokens ethereumservice addtokenaddress methereumaccount, tokenaddress setcallback new listenablefuturetask callback<ethereumaccount> { @override public void onsuccess ethereumaccount ethereumaccount { mprogressbar setvisibility view invisible ; log i tag, "add token successful " + ethereumaccount ; handler post new runnable { @override public void run { toast maketext getcontext , "add token successful", toast length_short show ; } } ; } @override public void onfailure @nonnull executionexception e { mprogressbar setvisibility view invisible ; log e tag, "add token failed " + e ; } @override public void oncancelled @nonnull interruptedexception e { mprogressbar setvisibility view invisible ; log e tag, "add token cancelled " + e ; } } ; get token balance fetch the balance of the added token using gettokenbalance api ethereumservice gettokenbalance mtokenaccount, ethereumblockparameter latest setcallback new listenablefuturetask callback<biginteger> { @override public void onsuccess biginteger biginteger { mprogressbar setvisibility view invisible ; bigdecimal tokendecimal = bigdecimal ten pow 18 ; bigdecimal balance = new bigdecimal biginteger divide tokendecimal ; log d tag, "gettokenbalance success " + balance ; handler post new runnable { @override public void run { tokenbalance settext balance tostring ; } } ; } @override public void onfailure @nonnull executionexception e { mprogressbar setvisibility view invisible ; log e tag, "gettokenbalance failed " + e ; } @override public void oncancelled @nonnull interruptedexception e { mprogressbar setvisibility view invisible ; log e tag, "gettokenbalance cancelled " + e ; } } ; transfer token to transfer tokens between accounts, set the receiver address and the amount of tokens to send the trusted ui of the samsung blockchain keystore hardware wallet appears upon pressing the send button in the app, showing all the information regarding the transaction for confirmation generate a transaction hash upon confirmation of the transaction ethereumservice sendtokentransaction mhardwarewalletmanager getconnectedhardwarewallet , mtokenaccount, mtoaddress, tokenaddress, maxpriorityfee, methereumfeeinfo getestimatedbasefee add maxpriorityfee , mgaslimit, msendtokenamount, null setcallback new listenablefuturetask callback<transactionresult> { @override public void onsuccess transactionresult transactionresult { mprogressbar setvisibility view invisible ; log i tag, "send token successful " + transactionresult gethash ; handler post new runnable { @override public void run { toast maketext getcontext , "transaction hash " + transactionresult gethash , toast length_short show ; } } ; } @override public void onfailure @nonnull executionexception e { mprogressbar setvisibility view invisible ; log e tag, "send token failed " + e ; } @override public void oncancelled @nonnull interruptedexception e { mprogressbar setvisibility view invisible ; log i tag, "send token cancelled " + e ; } } ; run the app after building the apk, follow the steps below to test the application on a samsung blockchain-compatible device in send token tab, click create account copy the generated account address go to eth faucet tab to open the free faucet site already added to the application paste the account address and press the send me eth button click the hash string under your transactions to open etherscan and wait until the transaction succeeded go to token faucet tab and press get token to add some tokens in the account confirm the transaction go back to send token tab, click add token and press token balance to see added tokens press gas limit and max priority fee lastly, press send to transfer tokens confirm the transaction check the transaction status and details by finding the account address or the generated transaction hash txn hash in goerli testnet explorer you're done! congratulations! you have successfully achieved the goal of this code lab now, you can develop a decentralized application that can transfer erc20 tokens using samsung blockchain platform sdk if you face any trouble, you may download this file token transaction complete code 2 73 mb to learn more about developing apps with samsung blockchain, visit developer samsung com/blockchain
Develop Samsung Blockchain
docresources sdk samsung blockchain platform sdk sdk version 1 2 03 | dec 29, 2023 | 2 49mb api reference javadoc doc version 1 2 03 | dec 29, 2023 | 372kb programming guide programming guide includes getting started, using the sblockchain class, explanation on how to implement features and glossary programming guide sample application sample application aerowallet includes most functions supported by samsung blockchain platform sdk sample application - aero wallet app version 1 2 03 | dec 29, 2023 | 3 41mb codelab contents create shopping application with samsung blockchain platform sdk and pay using ethereum network project files and instruction guide is also supported developing a simple blockchain payment application introduction to samsung blockchain platform sdk video
Develop Samsung Blockchain
docapi implementation samsung blockchain keystore api level get instance get seedhash check for mandatory app update is root seed backed up get supported coins get hd path get a list of addresses get a list of extended public keys sign a transaction is reboot authentication required go to samsung blockchain keystore settings handle error codes deeplinks samsung blockchain keystore api level samsung blockchain keystore api level plays a key role to ensure that the required api level of samsung blockchain keystore on a user’s device is properly installed to support the api that your android app tries to call for example, if your android app is trying to implement a new samsung blockchain keystore api that requires “api level 2”, your android app will need to check whether samsung blockchain keystore app installed on user’s device also supports api level 2 if a user’s app supports api level 1, then your app will need to guide users to update samsung blockchain keystore app to the latest version users can be directed to the update page in galaxy store otherwise, there will be a runtime exception due to api level exception when calling apis with level higher than the level supported by the user’s version the api level for each api will be mentioned in the javadoc, under “since” title, and developers can call “getkeystoreapilevel api” to check the current api level on the user’s device your android app will need to check the api level whenever needed – it may be at the beginning of running samsung blockchain keystore app or every time your app calls an api public void getkeystoreapilevel { int keystoreapilevel = scwservice getinstance getkeystoreapilevel ; boolean iskeystoreapisupported = keystoreapilevel > 0; } get instance scwservice getinstance will need to be used to call any of the apis provided by samsung blockchain keystore if samsung blockchain keystore is supported on the device, an instance will be returned if it is not available on the device, then null will be returned if null is returned, it means samsung blockchain keystore is not supported on the user’s device a different keystore or a wallet needs to be used scwservice scwserviceinstance = scwservice getinstance ; get seed hash getseedhash api aims to help developers distinguish two things 1 check whether user has set up samsung blockchain keystore 2 check whether root seed recovery phrase has been changed or not every time a new root seed or a wallet is created or restored, the seed hash in a string value will be changed actually, this is not the preimage of the real seed, but a pseudo hash value so, it is not possible to calculate the real seed with the pseudo one it is strongly recommended for the application to cache the returned hash value to reduce the number of times to check the derived address’s validity if the returned value is same as cached, the derived addresses are still valid, so the application keeps using these addresses otherwise, the application should refresh the addresses from new seed with getaddresslist or getextendedpublickeylist api whenever the application starts, it needs to call getseedhash in case that the returned value is a zero-length string, it means that there is no wallet in the samsung blockchain keystore so, the application ui needs to guide users to jump to samsung blockchain keystore to create a wallet with scwdeeplink main deeplink public void getseedhash { string seedhash = scwservice getinstance getseedhash ; boolean initialized = seedhash != null && seedhash length > 0 ; } check mandatory app update checkformandatoryappupdate api is to help developers check if a user must update samsung blockchain keystore because samsung blockchain keystore handles only one task at a time, make sure to not call the checkformandatoryappupdate api in the background as it may cause other api calls or requests to be cancelled if a mandatory app update is needed, users can be directed to the galaxy store using a deeplink, scwdeeplink galaxy_store otherwise, users will see the mandatory app update popups during an operation process, such as signing a transaction, and will need to update samsung blockchain keystore before proceeding note scwservice scwcheckformandatoryappupdatecallback will need to be implemented correspondingly scwservice scwcheckformandatoryappupdatecallback callback = new scwservice scwcheckformandatoryappupdatecallback { @override public void onmandatoryappupdateneeded boolean needed { if needed { startdeeplink scwdeeplink galaxy_store ; } } }; scwservice getinstance checkformandatoryappupdate callback ; how to handle the returned value a boolean needed value of whether a mandatory update is needed or not will be returned if needed, developers will need to guide users to go to samsung blockchain keystore app page in galaxy store to update is root seed backed up isrootseedbackedup api helps developers check if there is a backup of root seed since a user can create a wallet without a backup of root seed, developers can advise the user to make root seed backup if a backup of root seed is needed, the users will be directed to the page which backs up the mnemonic phrases in the samsung blockchain keystore using a deep link, scwdeeplink backup_wallet boolean isbackedup = scwservice getinstance isrootseedbackedup ; if !isbackedup { startdeeplink scwdeeplink backup_wallet ; } how to handle the returned value the result of root seed backup will be returned in a boolean type get supported coins getsupportedcoins api is used to find out which type of cryptocurrencies are supported, in case there is a different logic that developers must implement for different cryptocurrencies it is returned in an int array of standard coin types according to bip standard – for example, 60 for ethereum int[] supportedcoins = scwservice getinstance getsupportedcoins ; stringbuilder sb = new stringbuilder ; sb append "supported coins" append '\n' ; for int i = 0; i < supportedcoins length; i++ { sb append '[' append i append "] " append supportedcoins[i] append '\n' ; } string s = sb tostring ; get hd path gethdpath api helps developers derive hd path for a specified coin type this api can be used as a parameter when deriving an address and requesting to sign a transaction note that utxo-based cryptocurrency, such as bitcoin will not be supported for this api no callback will be needed for this api as hd path in string type will be returned immediately //derive hd path for the cryptocurrency that your app supports string ethereumhdpath = scwservice gethdpath scwcointype eth, 0 ; string klaytnhdpath = scwservice gethdpath scwcointype klay, 0 ; string tronhdpath = scwservice gethdpath scwcointype tron, 0 ; string stellarhdpath = scwservice gethdpath scwcointype xlm, 0 ; there are two parameters needed coin type and address index coin type use scwcointype class to specify the cryptocurrency that your app uses address index address index is like an account number it is recommended to use 0 as the default address index increasing the address index will generate a different account for example, if you need another ethereum account, then you can increase this address index to 1 if you need just one address for your service, then make sure to use the same coin type and same address index throughout your service so that user does not get confused with multiple addresses examples the returned value will be hd path in a string format this hd path will be needed for getaddresslist api and signing cryptocurrency apis scwservice gethdpath scwcointype eth, 0 will return “m/44’/60’/0’/0/0” scwservice gethdpath scwcointype eth, 1 will return “m/44’/60’/0’/0/1” scwservice gethdpath scwcointype klay, 0 will return “m/44’/8217’/0’/0/0” scwservice gethdpath scwcointype tron, 0 will return “m/44’/195’/0’/0/0” scwservice gethdpath scwcointype xlm, 0 will return “m/44’/148’/0’” for more details on hd path refer to key management section in understanding keystore you can find how hd path is used in samsung blockchain keystore get a list of addresses getaddresslist api allows developers to request to get a list of addresses that correspond to a list of hd paths a list of the hd path, compatible with bip-44 needs to be passed on to bring the addresses the depth of hd path should be between 3 and 6 also, scwservice scwgetaddresslistcallback will need to be implemented correspondingly scwservice scwgetaddresslistcallback callback = new scwservice scwgetaddresslistcallback { @override public void onsuccess list<string> addresslist { } @override public void onfailure int errorcode, string errormessage { //handle errors } }; string hdpath = scwservice gethdpath scwcointype eth, 0 ; arraylist<string> hdpathlist = new arraylist<> ; hdpathlist add hdpath ; scwservice getinstance getaddresslist callback, hdpathlist ; hierarchical deterministic path hd path examples hdpath for ethereum m/44'/60'/0'/0/0 hdpath for bitcoin m/44'/0'/0'/0/0 if you are unsure about what hd path is, then you can generate hd path with gethdpath api except for bitcoin how to handle the returned value the returned value will be a list of addresses in a list** format each address will correspond to the hd path in the arraylist minimize calling getaddresslist api by checking seed hash value to avoid calling getaddresslist api as much as possible, please utilize getseedhash api to check whether the root seed has been changed or not, since different seed hash value implies that the corresponding address has also been updated get a list of extended public keys getextendedpublickeylist api allows developers to request to get a list of extended public keys that correspond to a list of hd paths a list of the hd path, compatible with bip-44 needs to be passed on to bring the public key the depth of path should be between 3 and 6 take note that the scwservice scwgetextendedpublickeylistcallback will need to be implemented correspondingly scwservice scwgetextendedpublickeylistcallback callback = new scwservice scwgetextendedpublickeylistcallback { @override public void onsuccess list<byte[]> extendedpublickeylist { } @override public void onfailure int errorcode, string errormessage { //handle errors } }; string hdpath = scwservice gethdpath scwcointype eth, 0 ; arraylist<string> hdpathlist = new arraylist<> ; hdpathlist add hdpath ; scwservice getinstance getextendedpublickeylist callback, hdpathlist ; hierarchical deterministic path hd path examples hdpath for ethereum m/44'/60'/0'/0/0 hdpath for bitcoin m/44'/0'/0'/0/0 how to handle the returned value the returned value will be list <byte[]> that corresponds to each hd path requested in the arraylist each byte array is composed of 33 bytes of compressed public key and 32 bytes of chain code you can derive the child public key based on this data note that you need to derive the address of the compressed public key or call getaddresslist api to get the address minimize calling getextendedpublickeylist api by checking seed hash value use getseedhash api to check whether the root seed has been changed or not, since different seed hash value implies that corresponding public keys have also been updated sign a transaction there are seven apis that support signing cryptocurrency transactions ethereum, personal sign message in ethereum, bitcoin, klaytn, tron, personal sign message in tron, and stellar note only signing a transaction is included in the samsung blockchain keystore scope 1 signethtransaction api signethtransaction api as the name implies, sends a request to samsung blockchain keystore to sign an ethereum transaction likewise, scwservice scwsignethtransactioncallback will need to be implemented scwservice scwsignethtransactioncallback callback = new scwservice scwsignethtransactioncallback { @override public void onsuccess byte[] signedethtransaction { } @override public void onfailure int errorcode, string errormessage { //handle error } }; string toaddress = "0xe7425ee1bc64ab7c51ce3617cb83e76fd545f1a9"; string ethamount = "123 456789"; string ethgasprice = "12000000000"; string ethgaslimit = "21000"; string data = ""; long chainid = 1; string hdpath = scwservice gethdpath scwcointype eth, 0 ; byte[] encodedunsignedethtx = createrawtransaction toaddress, ethamount, ethgasprice, ethgaslimit, data ; private byte[] createrawtransaction param1, param2, … { //implement your code here } scwservice getinstance signethtransaction callback, encodedunsignedethtx, hdpath, chainid ; the parameters to take note are as follows encodedunsignedethtx a byte array of an rlp-encoded unsigned ethereum raw transaction hdpath hd path that corresponds to the address linked to your android app that also corresponds to the private key which is used for signing chainid chain id to prevent replay attacks between different chain for eip1559 transaction, chainid should be null how to handle the returned value the signed transaction will be returned in a byte array type in a rlp-encoded format 2 signethpersonalmessage api signethpersonalmessage api can be used to request to samsung blockchain keystore to sign a message in ethereum scwservice scwsignethpersonalmessagecallback will need to be implemented scwservice scwsignethpersonalmessagecallback callback = new scwservice scwsignethpersonalmessagecallback { @override public void onsuccess byte[] signedpersonalmessage { } @override public void onfailure int errorcode, string errormessage { //handle error } }; string hdpath = scwservice gethdpath scwcointype eth, 0 ; byte[] unsignedmsg = "to sign up, please sign this message " getbytes ; scwservice getinstance signethpersonalmessage callback, unsignedmsg, hdpath ; the parameters to take note are as follows unsignedmsg – a byte array of raw message to be signed by samsung blockchain keystore the "\u0019ethereum signed message \n" prefix will be added by samsung blockchain keystore, so your android app should not include the prefix in the message hdpath hd path that corresponds to the address linked to your android app that also corresponds to the private key which is used for signing how to handle the returned value the type of return is a byte array of signed message based on r, s, v values for a transaction’s signature respectively 3 signbtctransaction api signbtctransaction api can be used to create a request to samsung blockchain keystore to sign a bitcoin transaction the scwservice scwsignbtctransactioncallback will need to be implemented scwservice scwsignbtctransactioncallback callback = new scwservice scwsignbtctransactioncallback { @override public void onsuccess byte[] signedbtctransaction { } @override public void onfailure int errorcode, string errormessage { //handle error } }; list<utxo> utxos = new arraylist<> ; arraylist<string> inputhdpathlist = new arraylist<> ; string changehdpath = "m/44'/0'/0'/0/0"; string inputhdpath1 = "m/44'/0'/0'/0/0"; string inputhdpath2 = "m/44'/0'/0'/0/1"; utxos add getunspentoutputs inputhdpath1 ; utxos add getunspentoutputs inputhdpath2 ; transactionextended unsignedtx = makeunsignedtransaction networkparams, utxos, to, value, fee ; for int i = 0; i < unsignedtx getinputs size ; i++ { string inputhdpath = unsignedtx getinputs gethdpath i ; inputhdpathlist add inputhdpath ; } private transaction makeunsignedtransaction networkparameters networkparams, list<utxo> utxos, string to, long value, long fee { //make unsigned transaction among unspent outputs to spend value with fee //implement your code here } scwservice getinstance signbtctransaction callback, transaction, inputhdpathlist, changehdpath ; the parameters to take note are as follows transaction a byte array of a serialized unsigned bitcoin transaction to be signed by samsung blockchain keystore inputhdpathlist a list of hd path that corresponds to the addresses linked to the transaction inputs in transaction this list also corresponds to the private key which is used for signing bip-44, 49, 84 are supported and coin type “1” in hd path can be used for bitcoin test network parameter check samsung blockchain keystore will verify the requested transaction using transactioninput in transaction and inputhdpathlist each transactioninput should correspond to an hd path in inputhdpathlist if there are multiple transactioninput, then corresponding inputhdpathlist and transactioninputs should be listed in the same order changehdpath if there is a return change, then include the hd path that corresponds to the change address if the change address is not needed, then this value should be null how to handle the returned value the signed transaction will be returned in a byte array type 4 signklaytransaction api signklaytransaction api can be used to request to samsung blockchain keystore to sign a klaytn transaction scwservice scwsignklaytransactioncallback will need to be implemented scwservice scwsignklaytransactioncallback callback = new scwservice scwsignklaytransactioncallback { @override public void onsuccess byte[] signedklaytransaction { } @override public void onfailure int errorcode, string errormessage { //handle error } }; string hdpath = scwservice gethdpath scwcointype klay, 0 ; byte[] unsignedtransaction = getunsignedtx ; int klaytnchainid = 1001; scwservice getinstance signklaytransaction callback, unsignedtransaction, hdpath, klaytnchainid ; the parameters to take note are as follows unsignedtransaction a byte array of raw transaction to be signed by samsung blockchain keystore it is same as the sigrlp value mentioned in klaytn official document hdpath - hd path that corresponds to the public key linked to your android app that also corresponds to the private key which is used for signing klaytnchainid – the klaytn network id or the integer to identify the network "8217" is klaytn cypress mainnet and "1001" is klaytn baobab testnet how to handle the returned value the signed transaction will be returned in a byte array type in a rlp-encoded format 5 signtrxtransaction api signtrxtransaction api can be used to request to samsung blockchain keystore to sign a tron transaction scwservice scwsigntrxtransactioncallback will need to be implemented scwservice scwsigntrxtransactioncallback callback = new scwservice scwsigntrxtransactioncallback { @override public void onsuccess byte[] signedtrxtransaction { //handle signed tron transaction } @override public void onfailure int errorcode, string errormessage { //handle error } }; string hdpath = scwservice gethdpath scwcointype tron, 0 ; string from = “tdcmwosbafcegqqnuarnjghy4tabdcmdwi” string to = “tq6pm81jdc2ghruonytzgvpc7svyqcemeu”; int amount = 2; byte[] unsignedtransaction = createunsignedtransaction hdpath from, to, amount ; private byte[] createunsignedtransaction param1, param2, … { //implement your code here } scwservice getinstance signtrxtransaction callback, unsignedtransaction, hdpath ; the parameters to take note are as follows unsignedtransaction a byte array of raw tron transaction to be signed by samsung blockchain keystore hdpath - hd path that corresponds to the public key linked to your android app that also corresponds to the private key which is used for signing how to handle the returned value signed transaction will be returned in a byte array 6 signtrxpersonalmessage api signtrxpersonalmessage api can be used to request to the samsung blockchain keystore to sign a message in tron the scwservice scwsigntrxpersonalmessagecallback will need to be implemented scwservice scwsigntrxpersonalmessagecallback callback = new scwservice scwsigntrxpersonalmessagecallback { @override public void onsuccess byte[] signedpersonalmessage { } @override public void onfailure int errorcode, string errormessage { //handle error } }; string hdpath = scwservice gethdpath scwcointype tron, 0 ; byte[] unsignedmsg = "to sign up, please sign this message " getbytes ; scwservice getinstance signtrxpersonalmessage callback, unsignedmsg, hdpath ; the parameters to take note are as follows unsignedmsg a byte array of raw message to be signed by samsung blockchain keystore a "\u0019tron signed message \n32" prefix will be added by samsung blockchain keystore, so your android app should not include the prefix in the message hdpath hd path that corresponds to the address linked to your android app that also corresponds to the private key which is used for signing how to handle the returned value the type of return is a byte array of signed message based on values for a transaction’s signature - r, s, v respectively 7 signxlmtransaction api signxlmtransaction api can be used to request to the samsung blockchain keystore to sign a stellar transaction the scwservice scwsignxlmtransactioncallback will be needed to be implemented scwservice scwsignxlmtransactioncallback callback = new scwservice scwsignxlmtransactioncallback { @override public void onsuccess byte[] signedxlmtransaction { //handle signed stellar transaction } @override public void onfailure int errorcode, string errormessage { //handle error } }; string recipientaccount = “gay5dorarbd5l3fbbwuhxkciv7vcmqicsllj7gyr4664av4mxtx2fh4o”; string amount = “100”; paymentoperation operation = new paymentoperation builder recipientaccount, asset, amount build ; string hdpath = scwservice gethdpath scwcointype xlm, 0 ; arraylist<string> hdpathlist = new arraylist<> ; hdpathlist add hdpath ; string sourceaccount = “gb7zviydvsww3ctfj2v3oproahgbuomebwib55xieii3aq6523pg4lm5”; string memo = "hello12347"; byte[] unsignedtransaction = createunsignedtransaction sourceaccount, operation, memo, networkid ; private byte[] createunsignedtransaction param1, param2, … { //implement your code here // include networkid, envelopetype envelopte_type_tx , and xdr-encoded transaction } scwservice getinstance signxlmtransaction callback, unsignedtransaction, hdpathlist ; the parameters to take note are as follows unsignedtransaction – a byte array of raw transaction to be signed by samsung blockchain keystore it is the same as the signature base, which includes networkid, envelopetype, and xdr-encoded transaction hdpathlist a list of hd path that corresponds to the addresses linked to your android app that also corresponds to the private key which is used for signing how to handle the returned value the signed transaction will be returned in a byte array developers can use base64 encoding to implement this result into envelopexdr, which can derive the transaction that can be submitted to the network is reboot authentication required the isrebootauthenticationrequired api allows you to check whether pin authentication is required after reboot some keystore api calls can require pin authentication after device reboot these calls are successful only after the user enters their blockchain keystore pin at the prompt the isrebootauthenticationrequired method allows you to determine whether accessing the keystore api requires pin authentication boolean isrebootauthenticationrequired = scwservice getinstance isrebootauthenticationrequired ; if isrebootauthenticationrequired { // user prompted for pin authentication } else { // user not prompted for pin authentication } • handling the returned value the isrebootauthenticationrequired method returns a boolean value go to samsung blockchain keystore settings samsung blockchain keystore provides a user-friendly setup page for the first time users and a settings page for existing users developers can easily jump to samsung blockchain keystore settings by using a deeplink, scwdeeplink main there are two purposes of calling the samsung blockchain keystore main activity setup samsung blockchain keystore for first time users after calling getseedhash api, if the wallet is not created, a zero length value will be returned this is when your android app should call samsung blockchain keystore settings via a deep link as shown below samsung blockchain keystore will check if a user needs to set up a new wallet and if needed, will lead to a setup page after the activity is finished, your android app should call the getseedhash api, once more, to make sure that the wallet has been created and the corresponding seed hash value is returned samsung blockchain keystore settings for existing users for existing users, when samsung blockchain keystore settings is called, a user will see a list of menu related to samsung blockchain keystore management features include changing the pin, removing the wallet, checking a recovery phrase to back up the wallet, enabling/disabling fingerprint as an authentication method, or changing alarm notifications settings more information about the samsung blockchain keystore, such as notices, terms and conditions, and app information can be also found here a sample code for calling samsung blockchain keystore via a deeplink is as follows uri uri = uri parse scwdeeplink main ; intent intent = new intent intent action_view ; intent setdata uri ; intent setflags intent flag_activity_new_task ; mcontext startactivity intent ; *do not call startactivityforresult intent as no results will be returned make sure to use startactivity intent instead handling error codes in addition to general error codes, the following are some special cases that developers may want to look out for mandatory update is needed samsung blockchain keystore was removed due to user entering wrong pin more than n times api key is invalid the popups above will be shown from samsung blockchain keystore app, though the samsung blockchain keystore will still return corresponding error codes in the mandatory update error case, the user will see a popup with a link to galaxy apps store page to update samsung blockchain keystore if it was reset, due to entering a wrong pin more than n times, then the user will need to create or import the wallet via samsung blockchain keystore service again it is recommended that developers call checkformandatoryappupdate api before calling other apis, to check whether a mandatory app update is needed for this api, no ui or popup will be shown from samsung blockchain keystore upon integration, developers may receive an “error_package_signature_verification_failed” error in this case, developers can turn on developer mode to skip the app verification stage yet, developers will need to implement proper app id, officially issued by the samsung blockchain keystore team before launching your android app in the market public interface scwerrorcode { int error_mandatory_app_update_needed = -8; int error_package_signature_verification_failed = -11; int error_wallet_reset = -12; int error_check_app_version_failed = -15; int error_tnc_not_agreed = -6; } please refer to the scwerrorcode class in javadoc for more details on error codes samsung blockchain keystore deeplinks deep links to samsung blockchain keystore and deep link to update samsung blockchain keystore app in galaxy store are provided developers can implement the links below to direct users to go to the main page and back up root seed page in samsung blockchain keystore settings directly deep link to galaxy store can be used when user needs to update samsung blockchain keystore app features deeplink main page scwdeeplink main galaxy apps store scwdeeplink galaxy_store backup wallet scwdeeplink backup_wallet
We use cookies to improve your experience on our website and to show you relevant advertising. Manage you settings for our cookies below.
These cookies are essential as they enable you to move around the website. This category cannot be disabled.
These cookies collect information about how you use our website. for example which pages you visit most often. All information these cookies collect is used to improve how the website works.
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and tailor the website to provide enhanced features and content for you.
These cookies gather information about your browser habits. They remember that you've visited our website and share this information with other organizations such as advertisers.
You have successfully updated your cookie preferences.