<?xml version="1.0" encoding="us-ascii"?><InstanceReport xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Version>2.4.0.8</Version><ReportLongName>0012 - Disclosure - Related party transactions</ReportLongName><DisplayLabelColumn>true</DisplayLabelColumn><ShowElementNames>false</ShowElementNames><RoundingOption /><HasEmbeddedReports>false</HasEmbeddedReports><Columns><Column FlagID="0"><Id>1</Id><IsAbstractGroupTitle>false</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><CurrencyCode /><FootnoteIndexer /><hasSegments>false</hasSegments><hasScenarios>false</hasScenarios><MCU><KeyName /><CurrencySymbol /><contextRef><ContextID>From2013-01-01to2013-06-30</ContextID><EntitySchema>http://www.sec.gov/CIK</EntitySchema><EntityValue>0001373485</EntityValue><PeriodDisplayName /><PeriodType>duration</PeriodType><PeriodStartDate>2013-01-01T00:00:00</PeriodStartDate><PeriodEndDate>2013-06-30T00:00:00</PeriodEndDate><Segments /><Scenarios /></contextRef><UPS /><CurrencyCode /><OriginalCurrencyCode /></MCU><CurrencySymbol /><Labels><Label Key="CalendarSupplement" Id="0" Label="6 Months Ended" /><Label Key="Calendar" Id="1" Label="Jun. 30, 2013" /></Labels></Column></Columns><Rows><Row FlagID="0"><Id>1</Id><IsAbstractGroupTitle>true</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><Level>1</Level><ElementName>us-gaap_RelatedPartyTransactionsAbstract</ElementName><ElementPrefix>us-gaap_</ElementPrefix><IsBaseElement>true</IsBaseElement><BalanceType>na</BalanceType><PeriodType>duration</PeriodType><IsReportTitle>false</IsReportTitle><IsSegmentTitle>false</IsSegmentTitle><IsCalendarTitle>false</IsCalendarTitle><IsEquityPrevioslyReportedAsRow>false</IsEquityPrevioslyReportedAsRow><IsEquityAdjustmentRow>false</IsEquityAdjustmentRow><IsBeginningBalance>false</IsBeginningBalance><IsEndingBalance>false</IsEndingBalance><IsReverseSign>false</IsReverseSign><FootnoteIndexer /><Cells><Cell FlagID="0" ContextID="" UnitID=""><Id>1</Id><IsNumeric>false</IsNumeric><IsRatio>false</IsRatio><DisplayZeroAsNone>false</DisplayZeroAsNone><NumericAmount>0</NumericAmount><RoundedNumericAmount>0</RoundedNumericAmount><NonNumbericText /><FootnoteIndexer /><CurrencyCode /><CurrencySymbol /><IsIndependantCurrency>false</IsIndependantCurrency><ShowCurrencySymbol>false</ShowCurrencySymbol><DisplayDateInUSFormat>false</DisplayDateInUSFormat></Cell></Cells><ElementDataType>xbrli:stringItemType</ElementDataType><SimpleDataType>string</SimpleDataType><IsTotalLabel>false</IsTotalLabel><UnitID>0</UnitID><Label>Related Party Transactions [Abstract]</Label></Row><Row FlagID="0"><Id>2</Id><IsAbstractGroupTitle>false</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><Level>2</Level><ElementName>us-gaap_RelatedPartyTransactionsDisclosureTextBlock</ElementName><ElementPrefix>us-gaap_</ElementPrefix><IsBaseElement>true</IsBaseElement><BalanceType>na</BalanceType><PeriodType>duration</PeriodType><IsReportTitle>false</IsReportTitle><IsSegmentTitle>false</IsSegmentTitle><IsCalendarTitle>false</IsCalendarTitle><IsEquityPrevioslyReportedAsRow>false</IsEquityPrevioslyReportedAsRow><IsEquityAdjustmentRow>false</IsEquityAdjustmentRow><IsBeginningBalance>false</IsBeginningBalance><IsEndingBalance>false</IsEndingBalance><IsReverseSign>false</IsReverseSign><FootnoteIndexer /><Cells><Cell FlagID="0" ContextID="From2013-01-01to2013-06-30" UnitID=""><Id>1</Id><IsNumeric>false</IsNumeric><IsRatio>false</IsRatio><DisplayZeroAsNone>false</DisplayZeroAsNone><NumericAmount>0</NumericAmount><RoundedNumericAmount>0</RoundedNumericAmount><NonNumbericText>&lt;div style="text-indent: 0pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: center"&gt;&lt;div style="text-indent: 0pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: left"&gt;&lt;font style="display: inline; font: bold 10pt Times New Roman"&gt;7 &amp;#8211; Related party transactions&lt;/font&gt;&lt;/div&gt;

&lt;div style="text-indent: 0pt; display: block"&gt;&lt;br /&gt;
&lt;/div&gt;

&lt;div style="text-indent: 36pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: left"&gt;&lt;font style="display: inline; font: 10pt Times New Roman"&gt;On April 11, 2012, the Company advanced its then Chief Executive Officer, E. Willard Gray, II, $119,575 related to the change in control provisions in Mr. Gray's employment agreement.&amp;#160;&amp;#160;At June 30, 2012, $42,070 remained outstanding (shown as Accounts receivable - related party on the Balance Sheet), which was deducted from the second change of control payment to him from the Company in July 2012.&lt;/font&gt;&lt;/div&gt;

&lt;div style="text-indent: 0pt; display: block"&gt;&lt;br /&gt;
&lt;/div&gt;

&lt;div style="text-indent: 36pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: left"&gt;&lt;font style="display: inline; font: 10pt Times New Roman"&gt;During the year ended December 31, 2012, Red Mountain Resources, Inc. incurred approximately $628,274 for general and administrative expenses and operating costs that will be reimbursed by the Company for accounting services and attendance of certain of the Company&amp;#8217;s directors and officers at the Company&amp;#8217;s annual meeting of stockholders and for costs associated with workovers on three of the Company&amp;#8217;s salt water disposal wells, of which $215,495 remained unpaid at December 31, 2012.&amp;#160;&amp;#160;The expenditures pertaining to the operating costs were incurred pursuant to a technical services agreement between the Company and Red Mountain Resources, Inc.&amp;#160;&amp;#160;During the six months ended June 30, 2013, Red Mountain incurred approximately $490,508 of such expenditures, $409,391 of which remained unpaid at June 30, 2013.&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;</NonNumbericText><FootnoteIndexer /><CurrencyCode /><CurrencySymbol /><IsIndependantCurrency>false</IsIndependantCurrency><ShowCurrencySymbol>false</ShowCurrencySymbol><DisplayDateInUSFormat>false</DisplayDateInUSFormat></Cell></Cells><ElementDataType>nonnum:textBlockItemType</ElementDataType><SimpleDataType>na</SimpleDataType><ElementDefenition>The entire disclosure for related party transactions. Examples of related party transactions include transactions between (a) a parent company and its subsidiary; (b) subsidiaries of a common parent; (c) and entity and its principal owners; and (d) affiliates.</ElementDefenition><ElementReferences>Reference 1: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 850

 -SubTopic 10

 -Section 50

 -Paragraph 4

 -URI http://asc.fasb.org/extlink&amp;oid=6457730&amp;loc=d3e39622-107864



Reference 2: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 850

 -SubTopic 10

 -Section 50

 -Paragraph 3

 -URI http://asc.fasb.org/extlink&amp;oid=6457730&amp;loc=d3e39603-107864



Reference 3: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 850

 -SubTopic 10

 -Section 50

 -Paragraph 1

 -URI http://asc.fasb.org/extlink&amp;oid=6457730&amp;loc=d3e39549-107864



Reference 4: http://www.xbrl.org/2003/role/presentationRef

 -Publisher SEC

 -Name Regulation S-X (SX)

 -Number 210

 -Section 04

 -Paragraph b

 -Article 3A



Reference 5: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 235

 -SubTopic 10

 -Section S99

 -Paragraph 1

 -Subparagraph (SX 210.4-08.(k))

 -URI http://asc.fasb.org/extlink&amp;oid=26873400&amp;loc=d3e23780-122690



Reference 6: http://www.xbrl.org/2003/role/presentationRef

 -Publisher SEC

 -Name Regulation S-X (SX)

 -Number 210

 -Section 08

 -Paragraph k

 -Article 4



Reference 7: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 850

 -SubTopic 10

 -Section 50

 -Paragraph 6

 -URI http://asc.fasb.org/extlink&amp;oid=6457730&amp;loc=d3e39691-107864



Reference 8: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 850

 -SubTopic 10

 -Section 50

 -Paragraph 5

 -URI http://asc.fasb.org/extlink&amp;oid=6457730&amp;loc=d3e39678-107864



</ElementReferences><IsTotalLabel>false</IsTotalLabel><UnitID>0</UnitID><Label>Related party transactions</Label></Row></Rows><Footnotes /><IsEquityReport>false</IsEquityReport><ReportName>Related party transactions</ReportName><MonetaryRoundingLevel>UnKnown</MonetaryRoundingLevel><SharesRoundingLevel>UnKnown</SharesRoundingLevel><PerShareRoundingLevel>UnKnown</PerShareRoundingLevel><ExchangeRateRoundingLevel>UnKnown</ExchangeRateRoundingLevel><HasCustomUnits>true</HasCustomUnits><IsEmbedReport>false</IsEmbedReport><IsMultiCurrency>false</IsMultiCurrency><ReportType>Sheet</ReportType><RoleURI>http://xbres.com/role/RelatedPartyTransactions</RoleURI><NumberOfCols>1</NumberOfCols><NumberOfRows>2</NumberOfRows></InstanceReport>
